Skip to content

Commit e43371f

Browse files
committed
expect_warning in some noisy warning+error tests
A couple warnings were leaking out of `test()` from test cases that produced a warning + error but only used `expect_error()`. Use `expect_warning` in addition to test for specific expected warnings.
1 parent 81fb4bc commit e43371f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

tests/testthat/test-utils.R

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,23 @@ test_that("assert_sufficient_f_args alerts if the provided f has defaults for th
176176
class = "epiprocess__assert_sufficient_f_args__required_args_contain_defaults")
177177
expect_error(assert_sufficient_f_args(f_xsgt_dots, "b"),
178178
class = "epiprocess__assert_sufficient_f_args__required_args_contain_defaults")
179-
expect_error(assert_sufficient_f_args(f_xs_dots, "b"),
180-
class = "epiprocess__assert_sufficient_f_args__required_args_contain_defaults")
179+
expect_error(
180+
expect_warning(
181+
assert_sufficient_f_args(f_xs_dots, "b"),
182+
class = "epiprocess__assert_sufficient_f_args__mandatory_f_args_passed_to_f_dots"
183+
),
184+
class = "epiprocess__assert_sufficient_f_args__required_args_contain_defaults"
185+
)
181186

182187
# forwarding no dots should produce a different error message in some cases:
183-
expect_error(assert_sufficient_f_args(f_xs_dots),
184-
regexp = "window data and group key to `f`'s x and setting argument",
185-
class = "epiprocess__assert_sufficient_f_args__required_args_contain_defaults")
188+
expect_error(
189+
expect_warning(
190+
assert_sufficient_f_args(f_xs_dots),
191+
class = "epiprocess__assert_sufficient_f_args__mandatory_f_args_passed_to_f_dots"
192+
),
193+
regexp = "window data and group key to `f`'s x and setting argument",
194+
class = "epiprocess__assert_sufficient_f_args__required_args_contain_defaults"
195+
)
186196
})
187197

188198
test_that("computation formula-derived functions take all argument types", {

0 commit comments

Comments
 (0)