Skip to content

Commit

Permalink
Compatibility with dev testthat
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Jul 21, 2020
1 parent 1fe0bd1 commit bcfd66f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/testthat/helper-expectations.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ expect_syntactic <- function(name, exp_syn_name) {
}

expect_error_cnd <- function(object, class, message = NULL, ..., .fixed = TRUE) {
cnd <- expect_error(object, regexp = message, class = class, fixed = .fixed)
cnd <- expect_error(object, regexp = message, class = class[[1]], fixed = .fixed)
expect_true(inherits_all(cnd, class))

exp_fields <- list2(...)
Expand All @@ -101,7 +101,7 @@ expect_incompatible_df_cast <- function(x, fallback) {
}

expect_df_fallback_warning <- function(expr) {
expect_warning({{ expr }}, "falling back to (<data.frame>|<tibble>)")
suppressWarnings(expect_warning({{ expr }}, "falling back to (<data.frame>|<tibble>)"))
}
expect_df_fallback_warning_maybe <- function(expr) {
if (is_true(peek_option("vctrs:::warn_on_fallback"))) {
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-type-data-frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ test_that("combining data frames with foreign classes uses fallback", {
foo <- structure(mtcars[1:3], class = c("foo", "data.frame"))
bar <- structure(mtcars[4:6], class = c("bar", "data.frame"))
baz <- structure(mtcars[7:9], class = c("baz", "data.frame"))
expect_warning(vec_ptype_common_df_fallback(foo, bar, baz))
expect_warning(vec_ptype_common_df_fallback(foo, baz, bar, baz, foo, bar))
# Nested expect_warning() require testthat > 2.3.2
suppressWarnings(expect_warning(vec_ptype_common_df_fallback(foo, bar, baz)))
suppressWarnings(expect_warning(vec_ptype_common_df_fallback(foo, baz, bar, baz, foo, bar)))

with_fallback_warning(expect_df_fallback_warning(invisible(vec_rbind(foo, data.frame(), foo))))
with_fallback_warning(expect_df_fallback_warning(invisible(vec_cbind(foo, data.frame(x = 1)))))
Expand Down

0 comments on commit bcfd66f

Please sign in to comment.