Skip to content

expect_s3_class for class hierarchies #885

@krlmlr

Description

@krlmlr

What's a good way to test that an object inherits from multiple classes? expect_s3_class() uses inherits() which tests if the object inherits from one of the classes passed.

Can we add a new expect_s3_classes() ?

# This is expected
testthat::expect_s3_classes(tibble::tibble(), c("tbl_df", "data.frame"))
# This should be a failure?
testthat::expect_s3_classes(tibble::tibble(), c("tbl_df", "data.table"))

Created on 2019-06-15 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions