-
Notifications
You must be signed in to change notification settings - Fork 340
Closed
Description
Hi all,
When test_that() contains a failing test linked with warning classes, it seems that the test passes.
expect_warning(rlang::warn(class = "C1"), class = "C2")
provides the expected error:
Avis : Erreur : `rlang::warn(class = "C1")` did not throw a warning with class <C2>.
and yet, including it in test_that() does not result in a test fail
test_that("a C2 warning is expected",
{
expect_warning(rlang::warn(class = "C1"), class = "C2")
})
--> Test passed π
Symmetrically, when testing the absence of a warning of class C2 with expect_no_warning , the expected result is produced (no error)
expect_no_warning(
rlang::warn(class = "C1"),
class = "C2"
)
and yet, including it test_that
test_that("no C2 warning is expected",
{
expect_no_warning(
rlang::warn(class = "C1"),
class = "C2"
)
})
generates this unexpected console output:
ββ Warning: no C2 warning is expected βββββββββββββββββββββββ
Backtrace:
β
1. ββtestthat::expect_no_warning(rlang::warn(class = "C1"), class = "C2")
2. ββtestthat:::expect_no_(...)
3. ββtestthat:::quasi_capture(enquo(object), NULL, capture)
4. ββtestthat (local) .capture(...)
5. β ββrlang::try_fetch(...)
6. β ββbase::withCallingHandlers(...)
7. ββrlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
I guess the test is a success though, since the function output is TRUE, but this console backtrace may be inappropriate.
Is this expected ?
NB: I saw that a close issue was declared #1894 for edition 2, so I am using local_edition(3) here
Metadata
Metadata
Assignees
Labels
No labels