From 8d7612215ac61edcf521e61ce4046a5e447eb1ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sat, 22 Jan 2022 10:18:02 +0100 Subject: [PATCH] Avoid iris in tests --- tests/testthat/_snaps/ctl_colonnade.md | 54 ++++++++++---------------- tests/testthat/_snaps/format_list.md | 2 +- tests/testthat/_snaps/format_multi.md | 28 ++++++------- tests/testthat/_snaps/glimpse.md | 54 ++++++++++++-------------- tests/testthat/test-ctl_colonnade.R | 6 +-- tests/testthat/test-format_list.R | 2 +- tests/testthat/test-format_multi.R | 6 +-- tests/testthat/test-glimpse.R | 24 ++++++------ 8 files changed, 79 insertions(+), 97 deletions(-) diff --git a/tests/testthat/_snaps/ctl_colonnade.md b/tests/testthat/_snaps/ctl_colonnade.md index 12c634c9f..120946ba6 100644 --- a/tests/testthat/_snaps/ctl_colonnade.md +++ b/tests/testthat/_snaps/ctl_colonnade.md @@ -62,52 +62,38 @@ Code - ctl_colonnade(iris[1:5, ], width = 30) + ctl_colonnade(trees[1:5, ], width = 20) Output $body - Sepal.Length Sepal.Width - - 1 5.1 3.5 - 2 4.9 3 - 3 4.7 3.2 - 4 4.6 3.1 - 5 5 3.6 + Girth Height + + 1 8.3 70 + 2 8.6 65 + 3 8.8 63 + 4 10.5 72 + 5 10.7 81 $extra_cols - $extra_cols$Petal.Length - [1] 1.4 1.4 1.3 1.5 1.4 - - $extra_cols$Petal.Width - [1] 0.2 0.2 0.2 0.2 0.2 - - $extra_cols$Species - [1] setosa setosa setosa setosa setosa - Levels: setosa versicolor virginica + $extra_cols$Volume + [1] 10.3 10.3 10.2 16.4 18.8 Code - ctl_colonnade(iris[1:3, ], width = 20) + ctl_colonnade(trees[1:3, ], width = 10) Output $body - Sepal.Length - - 1 5.1 - 2 4.9 - 3 4.7 + Girth + + 1 8.3 + 2 8.6 + 3 8.8 $extra_cols - $extra_cols$Sepal.Width - [1] 3.5 3.0 3.2 - - $extra_cols$Petal.Length - [1] 1.4 1.4 1.3 - - $extra_cols$Petal.Width - [1] 0.2 0.2 0.2 + $extra_cols$Height + [1] 70 65 63 - $extra_cols$Species - [1] setosa setosa setosa - Levels: setosa versicolor virginica + $extra_cols$Volume + [1] 10.3 10.3 10.2 Code diff --git a/tests/testthat/_snaps/format_list.md b/tests/testthat/_snaps/format_list.md index cc88b43e0..1349f288c 100644 --- a/tests/testthat/_snaps/format_list.md +++ b/tests/testthat/_snaps/format_list.md @@ -23,7 +23,7 @@ Code - pillar(list(iris), width = 10) + pillar(list(trees), width = 10) Output diff --git a/tests/testthat/_snaps/format_multi.md b/tests/testthat/_snaps/format_multi.md index a636d7576..8a45b5374 100644 --- a/tests/testthat/_snaps/format_multi.md +++ b/tests/testthat/_snaps/format_multi.md @@ -363,23 +363,23 @@ 7 14.3 8 360 245 8 24.4 4 147. 62 Code - colonnade(iris[1:5, ], width = 30) + colonnade(trees[1:5, ], width = 20) Output - Sepal.Length Sepal.Width - - 1 5.1 3.5 - 2 4.9 3 - 3 4.7 3.2 - 4 4.6 3.1 - 5 5 3.6 + Girth Height + + 1 8.3 70 + 2 8.6 65 + 3 8.8 63 + 4 10.5 72 + 5 10.7 81 Code - colonnade(iris[1:3, ], width = 20) + colonnade(trees[1:3, ], width = 10) Output - Sepal.Length - - 1 5.1 - 2 4.9 - 3 4.7 + Girth + + 1 8.3 + 2 8.6 + 3 8.8 Code colonnade(df_all, width = 30) Output diff --git a/tests/testthat/_snaps/glimpse.md b/tests/testthat/_snaps/glimpse.md index 0afadddd2..809ac53e8 100644 --- a/tests/testthat/_snaps/glimpse.md +++ b/tests/testthat/_snaps/glimpse.md @@ -116,20 +116,18 @@ $ gear 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 4, 4~ $ carb 4, 4, 1, 1, 2, 1, 4, 2, 2, 4, 4, 3, 3, 3, 4, 4, 4, 1, 2~ Code - glimpse(as_tbl(iris), width = 70L) + glimpse(as_tbl(trees), width = 70L) Output - Rows: 150 - Columns: 5 - $ Sepal.Length 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.~ - $ Sepal.Width 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.~ - $ Petal.Length 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, 1.4, 1.~ - $ Petal.Width 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.~ - $ Species setosa, setosa, setosa, setosa, setosa, setosa,~ + Rows: 31 + Columns: 3 + $ Girth 8.3, 8.6, 8.8, 10.5, 10.7, 10.8, 11.0, 11.0, 11.1, 11~ + $ Height 70, 65, 63, 72, 81, 83, 66, 75, 80, 75, 79, 76, 76, 6~ + $ Volume 10.3, 10.3, 10.2, 16.4, 18.8, 19.7, 15.6, 18.2, 22.6,~ Code # No columns - glimpse(as_tbl(iris[integer()]), width = 70L) + glimpse(as_tbl(trees[integer()]), width = 70L) Output - Rows: 150 + Rows: 31 Columns: 0 Code # Non-syntactic names @@ -190,33 +188,31 @@ Output num 5 Code - iris2 <- as_unknown_rows(iris) - glimpse(iris2, width = 70L) + trees2 <- as_unknown_rows(trees) + glimpse(trees2, width = 70L) Output Rows: ?? - Columns: 5 - $ Sepal.Length 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.~ - $ Sepal.Width 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.~ - $ Petal.Length 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, 1.4, 1.~ - $ Petal.Width 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.~ - $ Species setosa, setosa, setosa, setosa, setosa, setosa,~ - Code - species <- unique(iris$Species) - data <- unname(split(iris, iris$Species)) - nested_iris_df <- tibble::tibble(species, data) - glimpse(nested_iris_df, width = 70L) + Columns: 3 + $ Girth 8.3, 8.6, 8.8, 10.5, 10.7, 10.8, 11.0, 11.0, 11.1, 11~ + $ Height 70, 65, 63, 72, 81, 83, 66, 75, 80, 75, 79, 76, 76, 6~ + $ Volume 10.3, 10.3, 10.2, 16.4, 18.8, 19.7, 15.6, 18.2, 22.6,~ + Code + cyl <- unique(mtcars$cyl) + data <- unname(split(mtcars, mtcars$cyl)) + nested_mtcars_df <- tibble::tibble(cyl, data) + glimpse(nested_mtcars_df, width = 70L) Output Rows: 3 Columns: 2 - $ species setosa, versicolor, virginica - $ data [], [], [ 6, 4, 8 + $ data [], [], [ setosa, versicolor, virginica - $ data [], [], [] + $ cyl 6, 4, 8 + $ data [], [], [] diff --git a/tests/testthat/test-ctl_colonnade.R b/tests/testthat/test-ctl_colonnade.R index b00951496..96cedeaaf 100644 --- a/tests/testthat/test-ctl_colonnade.R +++ b/tests/testthat/test-ctl_colonnade.R @@ -10,8 +10,8 @@ test_that("tests from tibble", { expect_snapshot({ ctl_colonnade(mtcars[1:8, ], has_row_id = "*", width = 30) - ctl_colonnade(iris[1:5, ], width = 30) - ctl_colonnade(iris[1:3, ], width = 20) + ctl_colonnade(trees[1:5, ], width = 20) + ctl_colonnade(trees[1:3, ], width = 10) ctl_colonnade(df_all, width = 30) ctl_colonnade(df_all, width = 300) options(width = 70) @@ -40,7 +40,7 @@ test_that("empty", { character() ) expect_equal( - format(ctl_colonnade(iris[1:5, character()], width = 30)$body), + format(ctl_colonnade(trees[1:5, character()], width = 30)$body), character() ) }) diff --git a/tests/testthat/test-format_list.R b/tests/testthat/test-format_list.R index 47c28c303..6ff5c35de 100644 --- a/tests/testthat/test-format_list.R +++ b/tests/testthat/test-format_list.R @@ -3,6 +3,6 @@ test_that("output test", { pillar(as.list(1:3)) pillar(list(1:3, NULL)) pillar(add_special(list(1:3))) - pillar(list(iris), width = 10) + pillar(list(trees), width = 10) }) }) diff --git a/tests/testthat/test-format_multi.R b/tests/testthat/test-format_multi.R index 27c94e68c..00583966f 100644 --- a/tests/testthat/test-format_multi.R +++ b/tests/testthat/test-format_multi.R @@ -98,8 +98,8 @@ test_that("tests from tibble", { expect_snapshot({ colonnade(mtcars[1:8, ], has_row_id = "*", width = 30) - colonnade(iris[1:5, ], width = 30) - colonnade(iris[1:3, ], width = 20) + colonnade(trees[1:5, ], width = 20) + colonnade(trees[1:3, ], width = 10) colonnade(df_all, width = 30) colonnade(df_all, width = 300) options(width = 70) @@ -128,7 +128,7 @@ test_that("empty", { as_glue(character()) ) expect_equal( - format(colonnade(iris[1:5, character()], width = 30)), + format(colonnade(trees[1:5, character()], width = 30)), as_glue(character()) ) }) diff --git a/tests/testthat/test-glimpse.R b/tests/testthat/test-glimpse.R index b34782653..accab0164 100644 --- a/tests/testthat/test-glimpse.R +++ b/tests/testthat/test-glimpse.R @@ -46,10 +46,10 @@ test_that("glimpse calls tbl_sum() (#550)", { local_override_tbl_sum() - iris2 <- as_override_tbl_sum(iris) + trees2 <- as_override_tbl_sum(trees) expect_output( - glimpse(iris2), + glimpse(trees2), "Overridden: tbl_sum", fixed = TRUE ) @@ -61,10 +61,10 @@ test_that("output test for glimpse()", { expect_snapshot({ glimpse(as_tbl(mtcars), width = 70L) - glimpse(as_tbl(iris), width = 70L) + glimpse(as_tbl(trees), width = 70L) "No columns" - glimpse(as_tbl(iris[integer()]), width = 70L) + glimpse(as_tbl(trees[integer()]), width = 70L) "Non-syntactic names" df <- tibble::tibble(!!!set_names(c(5, 3), c("mean(x)", "var(x)"))) @@ -87,16 +87,16 @@ test_that("output test for glimpse()", { "non-tibble" glimpse(5) - iris2 <- as_unknown_rows(iris) - glimpse(iris2, width = 70L) + trees2 <- as_unknown_rows(trees) + glimpse(trees2, width = 70L) - species <- unique(iris$Species) - data <- unname(split(iris, iris$Species)) - nested_iris_df <- tibble::tibble(species, data) - glimpse(nested_iris_df, width = 70L) + cyl <- unique(mtcars$cyl) + data <- unname(split(mtcars, mtcars$cyl)) + nested_mtcars_df <- tibble::tibble(cyl, data) + glimpse(nested_mtcars_df, width = 70L) data <- map(data, as_tbl) - nested_iris_tbl <- tibble::tibble(species, data) - glimpse(nested_iris_tbl, width = 70L) + nested_mtcars_tbl <- tibble::tibble(cyl, data) + glimpse(nested_mtcars_tbl, width = 70L) }) })