testthat icon indicating copy to clipboard operation
testthat copied to clipboard

expect_snapshot() fails when names contain backquotes

Open moodymudskipper opened this issue 2 years ago • 1 comments

When running such test:

test_that("backquotes", {
  expect_snapshot(
    c("`a`" = 1)
  )
})

I get :

`c(`\`a\`` = 2)` threw an unexpected error.
Message: attempt to use zero-length variable name
Class:   simpleError/error/condition

moodymudskipper avatar May 02 '23 16:05 moodymudskipper

This looks like an rlang bug: https://github.com/r-lib/rlang/issues/1642

However maybe we should just use deparse() instead of expr_deparse().

hadley avatar Jul 26 '23 19:07 hadley

I tried using deparse() instead of expr_deparse() and I definitely did like the output (and it's likely to affect a bunch of existing snapshots). So we'll need to fix this in rlang.

hadley avatar Aug 05 '25 16:08 hadley