From 00042d6bc3b16d408897400b3f6a839156eb68f0 Mon Sep 17 00:00:00 2001 From: Albert Hattingh Date: Tue, 27 Feb 2024 23:50:27 +1100 Subject: [PATCH] updated testthat report format to match latest version --- tests/testthat/_snaps/coercion.md | 32 +++++++++++--- tests/testthat/_snaps/col-names.md | 10 +++-- tests/testthat/_snaps/col-types.md | 46 +++++++++++-------- tests/testthat/_snaps/dates.md | 6 ++- tests/testthat/_snaps/problems.md | 15 ++++--- tests/testthat/_snaps/read-excel.md | 68 +++++++++++++++++------------ tests/testthat/_snaps/sheets.md | 32 ++++++++------ 7 files changed, 135 insertions(+), 74 deletions(-) diff --git a/tests/testthat/_snaps/coercion.md b/tests/testthat/_snaps/coercion.md index 6cc51313..aeb59be0 100644 --- a/tests/testthat/_snaps/coercion.md +++ b/tests/testthat/_snaps/coercion.md @@ -3,8 +3,10 @@ Code df <- read_excel(test_sheet("types.xls"), sheet = "logical_coercion", col_types = c("logical", "text")) - Warning + Condition + Warning: Expecting logical in A14 / R14C1: got 'cabbage' + Warning: Expecting logical in A18 / R18C1: got a date --- @@ -12,28 +14,38 @@ Code df <- read_excel(test_sheet("types.xlsx"), sheet = "logical_coercion", col_types = c("logical", "text")) - Warning + Condition + Warning: Expecting logical in A14 / R14C1: got 'cabbage' + Warning: Expecting logical in A18 / R18C1: got a date # contaminated, explicit date is read as date Code df <- read_excel(test_sheet("types.xls"), sheet = "date_coercion", col_types = "date") - Warning + Condition + Warning: Expecting date in A4 / R4C1: got boolean + Warning: Expecting date in A5 / R5C1: got 'cabbage' + Warning: Coercing numeric to date in A6 / R6C1 + Warning: Coercing numeric to date in A7 / R7C1 --- Code df <- read_excel(test_sheet("types.xlsx"), sheet = "date_coercion", col_types = "date") - Warning + Condition + Warning: Expecting date in A4 / R4C1: got boolean + Warning: Expecting date in A5 / R5C1: got 'cabbage' + Warning: Coercing numeric to date in A6 / R6C1 + Warning: Coercing numeric to date in A7 / R7C1 # contaminated, explicit numeric is read as numeric @@ -41,10 +53,14 @@ Code df <- read_excel(test_sheet("types.xls"), sheet = "numeric_coercion", col_types = "numeric") - Warning + Condition + Warning: Coercing text to numeric in A3 / R3C1: '72' + Warning: Coercing boolean to numeric in A5 / R5C1 + Warning: Expecting numeric in A6 / R6C1: got a date + Warning: Expecting numeric in A7 / R7C1: got 'cabbage' --- @@ -52,9 +68,13 @@ Code df <- read_excel(test_sheet("types.xlsx"), sheet = "numeric_coercion", col_types = "numeric") - Warning + Condition + Warning: Coercing text to numeric in A3 / R3C1: '72' + Warning: Coercing boolean to numeric in A5 / R5C1 + Warning: Expecting numeric in A6 / R6C1: got a date + Warning: Expecting numeric in A7 / R7C1: got 'cabbage' diff --git a/tests/testthat/_snaps/col-names.md b/tests/testthat/_snaps/col-names.md index 1fc559f9..d223e3d9 100644 --- a/tests/testthat/_snaps/col-names.md +++ b/tests/testthat/_snaps/col-names.md @@ -2,13 +2,15 @@ Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), col_names = LETTERS[1:3]) - Error - Sheet 1 has 5 columns (5 unskipped), but `col_names` has length 3. + Condition + Error: + ! Sheet 1 has 5 columns (5 unskipped), but `col_names` has length 3. --- Code read_excel(test_sheet("iris-excel-xls.xls"), col_names = LETTERS[1:3]) - Error - Sheet 1 has 5 columns (5 unskipped), but `col_names` has length 3. + Condition + Error: + ! Sheet 1 has 5 columns (5 unskipped), but `col_names` has length 3. diff --git a/tests/testthat/_snaps/col-types.md b/tests/testthat/_snaps/col-types.md index 8313c6a9..fc0fbae9 100644 --- a/tests/testthat/_snaps/col-types.md +++ b/tests/testthat/_snaps/col-types.md @@ -3,15 +3,16 @@ Code read_excel(test_sheet("types.xlsx"), col_types = c("foo", "numeric", "text", "bar")) - Error - Illegal column type: 'foo' [1], 'bar' [4] + Condition + Error: + ! Illegal column type: 'foo' [1], 'bar' [4] # request for 'blank' col type gets deprecation message and fix Code read_excel(test_sheet("types.xlsx"), col_types = rep_len(c("blank", "text"), length.out = 5)) - Message + Message `col_type = "blank"` deprecated. Use "skip" instead. Output # A tibble: 5 x 2 @@ -27,64 +28,75 @@ Code read_excel(test_sheet("types.xlsx"), col_types = character()) - Error - length(col_types) > 0 is not TRUE + Condition + Error in `check_col_types()`: + ! length(col_types) > 0 is not TRUE --- Code read_excel(test_sheet("types.xlsx"), col_types = 1:3) - Error - is.character(col_types) is not TRUE + Condition + Error in `check_col_types()`: + ! is.character(col_types) is not TRUE --- Code read_excel(test_sheet("types.xlsx"), col_types = c(NA, "text", "numeric")) - Error - !anyNA(col_types) is not TRUE + Condition + Error in `check_col_types()`: + ! !anyNA(col_types) is not TRUE # guess_max is honored for col_types Code types <- read_excel(test_sheet("types.xlsx"), sheet = "guess_max", guess_max = 2) - Warning + Condition + Warning: Expecting numeric in A4 / R4C1: got 'ab' --- Code types <- read_excel(test_sheet("types.xls"), sheet = "guess_max", guess_max = 2) - Warning + Condition + Warning: Expecting numeric in A4 / R4C1: got 'ab' # wrong length col types generates error Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), col_types = c("numeric", "text")) - Error - Sheet 1 has 5 columns, but `col_types` has length 2. + Condition + Error: + ! Sheet 1 has 5 columns, but `col_types` has length 2. --- Code read_excel(test_sheet("iris-excel-xls.xls"), col_types = c("numeric", "text")) - Error - Sheet 1 has 5 columns, but `col_types` has length 2. + Condition + Error: + ! Sheet 1 has 5 columns, but `col_types` has length 2. # numeric is correctly coerced to logical [xlsx] Code df <- read_xlsx(test_sheet("missing-values-xlsx.xlsx"), guess_max = 0) - Warning + Condition + Warning: Expecting logical in A2 / R2C1: got 'NA' + Warning: Expecting logical in B2 / R2C2: got 'NA' # numeric is correctly coerced to logical [xls] Code df <- read_xls(test_sheet("missing-values-xls.xls"), guess_max = 0) - Warning + Condition + Warning: Expecting logical in A2 / R2C1: got 'NA' + Warning: Expecting logical in B2 / R2C2: got 'NA' diff --git a/tests/testthat/_snaps/dates.md b/tests/testthat/_snaps/dates.md index 315a9d3c..481e105b 100644 --- a/tests/testthat/_snaps/dates.md +++ b/tests/testthat/_snaps/dates.md @@ -3,7 +3,8 @@ Code df <- read_excel(test_sheet("dates-leap-year-1900-xlsx.xlsx"), col_types = c( "date", "text", "logical")) - Warning + Condition + Warning in `read_fun()`: NA inserted for impossible 1900-02-29 datetime # we get correct dates prior to March 1, 1900, in 1900 date system [xls] @@ -11,6 +12,7 @@ Code df <- read_excel(test_sheet("dates-leap-year-1900-xls.xls"), col_types = c( "date", "text", "logical")) - Warning + Condition + Warning in `read_fun()`: NA inserted for impossible 1900-02-29 datetime diff --git a/tests/testthat/_snaps/problems.md b/tests/testthat/_snaps/problems.md index fe791684..bc8f3d62 100644 --- a/tests/testthat/_snaps/problems.md +++ b/tests/testthat/_snaps/problems.md @@ -2,7 +2,8 @@ Code read_excel(test_sheet("geometry.xlsx"), sheet = "warning_B6", col_types = "numeric") - Warning + Condition + Warning: Expecting numeric in B6 / R6C2: got 'wtf' Output # A tibble: 3 x 1 @@ -16,7 +17,8 @@ Code read_excel(test_sheet("geometry.xlsx"), sheet = "warning_AT6", col_types = "numeric") - Warning + Condition + Warning: Expecting numeric in AT6 / R6C46: got 'wtf' Output # A tibble: 3 x 1 @@ -30,7 +32,8 @@ Code read_excel(test_sheet("geometry.xlsx"), sheet = "warning_AKE6", col_types = "numeric") - Warning + Condition + Warning: Expecting numeric in AKE6 / R6C967: got 'wtf' Output # A tibble: 3 x 1 @@ -44,7 +47,8 @@ Code read_excel(test_sheet("geometry.xls"), sheet = "warning_B6", col_types = "numeric") - Warning + Condition + Warning: Expecting numeric in B6 / R6C2: got 'wtf' Output # A tibble: 3 x 1 @@ -58,7 +62,8 @@ Code read_excel(test_sheet("geometry.xls"), sheet = "warning_AT6", col_types = "numeric") - Warning + Condition + Warning: Expecting numeric in AT6 / R6C46: got 'wtf' Output # A tibble: 3 x 1 diff --git a/tests/testthat/_snaps/read-excel.md b/tests/testthat/_snaps/read-excel.md index ff9581f8..ccac53af 100644 --- a/tests/testthat/_snaps/read-excel.md +++ b/tests/testthat/_snaps/read-excel.md @@ -2,8 +2,9 @@ Code read_xls(test_sheet("iris-excel-xlsx.xlsx")) - Error - + Condition + Error: + ! filepath: 'VOLATILE_FILEPATH' libxls error: Unable to open file @@ -11,90 +12,103 @@ Code read_xlsx(test_sheet("iris-excel-xls.xls")) - Error - zip file 'VOLATILE_FILEPATH' cannot be opened + Condition + Error in `utils::unzip()`: + ! zip file 'VOLATILE_FILEPATH' cannot be opened # non-existent file throws error Code read_excel("foo") - Error - `path` does not exist: 'foo' + Condition + Error: + ! `path` does not exist: 'foo' # read_excel catches invalid guess_max Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), guess_max = NA) - Error - `guess_max` must be a positive integer + Condition + Error: + ! `guess_max` must be a positive integer --- Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), guess_max = -1) - Error - `guess_max` must be a positive integer + Condition + Error: + ! `guess_max` must be a positive integer --- Code out <- read_excel(test_sheet("iris-excel-xlsx.xlsx"), guess_max = Inf) - Warning + Condition + Warning: `guess_max` is a very large value, setting to `21474836` to avoid exhausting memory --- Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), guess_max = NULL) - Error - `guess_max` must be a positive integer + Condition + Error: + ! `guess_max` must be a positive integer --- Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), guess_max = 1:2) - Error - `guess_max` must be a positive integer + Condition + Error: + ! `guess_max` must be a positive integer # read_excel catches invalid n_max Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), n_max = NA) - Error - `n_max` must be a positive integer + Condition + Error: + ! `n_max` must be a positive integer --- Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), n_max = -1) - Error - `n_max` must be a positive integer + Condition + Error: + ! `n_max` must be a positive integer --- Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), n_max = NULL) - Error - `n_max` must be a positive integer + Condition + Error: + ! `n_max` must be a positive integer --- Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), n_max = 1:2) - Error - `n_max` must be a positive integer + Condition + Error: + ! `n_max` must be a positive integer # sheet must be integer or string Code read_excel(test_sheet("mtcars.xls"), sheet = TRUE) - Error - `sheet` must be either an integer or a string. + Condition + Error: + ! `sheet` must be either an integer or a string. # trim_ws must be a logical Code read_excel(test_sheet("mtcars.xls"), trim_ws = "yes") - Error - `trim_ws` must be either TRUE or FALSE + Condition + Error: + ! `trim_ws` must be either TRUE or FALSE diff --git a/tests/testthat/_snaps/sheets.md b/tests/testthat/_snaps/sheets.md index 10cb2037..cd4d1922 100644 --- a/tests/testthat/_snaps/sheets.md +++ b/tests/testthat/_snaps/sheets.md @@ -2,50 +2,56 @@ Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), sheet = "tulip") - Error - Sheet 'tulip' not found + Condition + Error: + ! Sheet 'tulip' not found --- Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), range = "tulip!A1:A1") - Error - Sheet 'tulip' not found + Condition + Error: + ! Sheet 'tulip' not found # informative error when requesting non-existent sheet by position Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), sheet = 2) - Error - Can't retrieve sheet in position 2, only 1 sheet(s) found. + Condition + Error: + ! Can't retrieve sheet in position 2, only 1 sheet(s) found. --- Code read_excel(test_sheet("iris-excel-xls.xls"), sheet = 2) - Error - Can't retrieve sheet in position 2, only 1 sheet(s) found. + Condition + Error: + ! Can't retrieve sheet in position 2, only 1 sheet(s) found. # invalid sheet values caught Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), sheet = 0) - Error - `sheet` must be positive + Condition + Error: + ! `sheet` must be positive --- Code read_excel(test_sheet("iris-excel-xlsx.xlsx"), sheet = rep(1L, 2)) - Error - `sheet` must have length 1 + Condition + Error: + ! `sheet` must have length 1 # double specification of sheet generates message and range wins Code double <- read_excel(test_sheet("sheet-xml-lookup.xlsx"), sheet = "Asia", range = "Oceania!A1:A1") - Message + Message Two values given for `sheet`. Using the `sheet` found in `range`: Oceania