Skip to content

expect_equal cannot replicate expect_equivalent's behavior #1241

Closed

Description

@egonulates

Since expect_equivalent function deprecated, I tried to use expect_equal(ignore_attr = TRUE) without any success:

library(testthat)

x <- 1
(y <- setNames(1, 'a'))
#> a 
#> 1

# Old function working perfectly
expect_equivalent(x, y)
# New function does not work
expect_equal(x, y, ignore_attr = TRUE)
#> Error: `x` not equal to `y`.
#> names for current but not for target

Activity

  1. hadley commented on Nov 19, 2020

    @hadley
    Member

    expect_equal() no longer ignores names because they're so important for describing details. I'd recommend using an explicit unname() instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions