Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expect_error and friends report unused arguments for fixed when used interactively but not when used non-interactively #1932

Open
billdenney opened this issue Feb 15, 2024 · 1 comment

Comments

@billdenney
Copy link
Contributor

When I ran the code below interactively, I got the following warning:

Error: 1 did not throw the expected warning.
Warning in expect_warning(1, regexp = "foo", fixed = TRUE) :
  Arguments in `...` must be used.
✖ Problematic argument:
• fixed = TRUE
ℹ Did you misspell an argument name?

But when run in reprex, I don't see the warning about fixed. Why is there different behavior for interactive vs non-interactive use for argument matching?

library(testthat)

expect_message(
  message("foo"),
  regexp = "foo",
  fixed = TRUE
)
  
expect_message(
  1,
  regexp = "foo",
  fixed = TRUE
)
#> Error: 1 did not produce any messages.

expect_warning(
  warning("foo"),
  regexp = "foo",
  fixed = TRUE
)

expect_warning(
  1,
  regexp = "foo",
  fixed = TRUE
)
#> Error: 1 did not produce any warnings.

expect_error(
  stop("foo"),
  regexp = "foo",
  fixed = TRUE
)

expect_error(
  1,
  regexp = "foo",
  fixed = TRUE
)
#> Error: 1 did not throw an error.

Created on 2024-02-15 with reprex v2.1.0

@hadley
Copy link
Member

hadley commented Apr 17, 2024

Somewhat more minimal reprex, but must be run interactively:

testthat::expect_message(1, "x", fixed = TRUE)

This is going to be a fun one to debug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants