diff --git a/R/expect-no-condition.R b/R/expect-no-condition.R index 678ac178e..8d87b2aec 100644 --- a/R/expect-no-condition.R +++ b/R/expect-no-condition.R @@ -96,7 +96,10 @@ expect_no_ <- function(base_class, capture <- function(code) { try_fetch( - code, + { + code + NULL + }, !!base_class := function(cnd) { if (!matcher(cnd)) { return(zap()) diff --git a/tests/testthat/test-expect-no-condition.R b/tests/testthat/test-expect-no-condition.R index 58718e71e..cd66a5e12 100644 --- a/tests/testthat/test-expect-no-condition.R +++ b/tests/testthat/test-expect-no-condition.R @@ -13,10 +13,12 @@ test_that("expect_no_* conditions behave as expected", { }) test_that("expect_no_* pass with pure code", { - expect_no_error(1) - expect_no_warning(1) - expect_no_message(1) - expect_no_condition(1) + expect_success(out <- expect_no_error(1)) + expect_equal(out, 1) + + expect_success(expect_no_warning(1)) + expect_success(expect_no_message(1)) + expect_success(expect_no_condition(1)) }) test_that("expect_no_* don't emit success when they fail", {