testthat icon indicating copy to clipboard operation
testthat copied to clipboard

expect_setequal error message is reversed

Open ambevill opened this issue 1 year ago • 2 comments

When expect_setequal fails, the labels are reversed:

Only in expected: {values that are only in the object} Only in actual: {values that are only in the expected}

Test case:

testthat::expect_setequal(object = 'actual', expected = 'expected')
Error: sample(c("actual", letters)) (`actual`) and sample(c("expected", letters)) (`expected`) don't have the same values.
* Only in `expected`: "actual"
* Only in `actual`: "expected"

A more complex test case:

testthat::expect_setequal(
  object = sample(c('actual', letters)),
  expected = sample(c('expected', letters)))

...gives the same result.

testthat 3.2.1.1 Windows binary R 4.2.2

ambevill avatar May 16 '24 11:05 ambevill

  • https://github.com/r-lib/testthat/blob/main/R/expect-setequal.R lines 45 and 47
  • https://github.com/r-lib/testthat/blob/main/tests/testthat/_snaps/expect-setequal.md (basically all of the messages)

ambevill avatar May 16 '24 11:05 ambevill

I am so bad at these 😭

hadley avatar Oct 22 '24 22:10 hadley