From acc3577d76b0083886e0bce34462f1c7db60b1aa Mon Sep 17 00:00:00 2001 From: jgabry Date: Tue, 26 Nov 2024 17:04:38 -0700 Subject: [PATCH] suppress more output during tests to clean up logs --- tests/testthat/test-failed-chains.R | 9 ++++++--- tests/testthat/test-fit-mcmc.R | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-failed-chains.R b/tests/testthat/test-failed-chains.R index 7ec86c3ed..7a67cf2c9 100644 --- a/tests/testthat/test-failed-chains.R +++ b/tests/testthat/test-failed-chains.R @@ -179,9 +179,12 @@ test_that("gq chains error on wrong input CSV", { mod <- testing_model("bernoulli_ppc") data_list <- testing_data("bernoulli_ppc") suppressWarnings( - expect_message( - mod$generate_quantities(data = data_list, fitted_params = fit_logistic$output_files()), - "Mismatch between model and fitted_parameters csv" + expect_output( + expect_message( + mod$generate_quantities(data = data_list, fitted_params = fit_logistic$output_files()), + "Mismatch between model and fitted_parameters csv" + ), + "Running standalone generated quantities" ) ) expect_warning( diff --git a/tests/testthat/test-fit-mcmc.R b/tests/testthat/test-fit-mcmc.R index f7e227d48..5e81dd713 100644 --- a/tests/testthat/test-fit-mcmc.R +++ b/tests/testthat/test-fit-mcmc.R @@ -285,7 +285,9 @@ test_that("loo method works with moment-matching", { # Moment-matching needs model-methods, so make sure hpp is available mod <- cmdstan_model(testing_stan_file("loo_moment_match"), force_recompile = TRUE) data_list <- testing_data("loo_moment_match") - fit <- mod$sample(data = data_list, chains = 1, seed = 1000) + utils::capture.output( + fit <- mod$sample(data = data_list, chains = 1, seed = 1000) + ) # Regular loo should warn that some pareto-k are "too high" expect_warning(