Skip to content

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

@billdenney

Description

@billdenney

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3e 📚featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions