Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for testthat 3.2.0 release #463

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Suggests:
rmarkdown,
rstanarm,
see,
testthat (>= 3.1.6),
testthat (>= 3.2.0),
tibble,
tidyr,
withr
Expand Down
23 changes: 23 additions & 0 deletions tests/testthat/_snaps/contr.deviation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# contr.deviation | snapshot

Code
solve(c.deviation)
Output
4 6 8
Intercept 0.3333333 0.3333333 0.3333333
6 -1.0000000 1.0000000 0.0000000
8 -1.0000000 0.0000000 1.0000000

---

Code
solve(mm)
Output
cyl4.am0 cyl4.am1 cyl6.am0 cyl6.am1 cyl8.am0 cyl8.am1
(Intercept) 0.3333333 0.0000000 0.3333333 0.0000000 0.3333333 0.0000000
cyl6 -1.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000
cyl8 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000
am1 -0.3333333 0.3333333 -0.3333333 0.3333333 -0.3333333 0.3333333
cyl6:am1 1.0000000 -1.0000000 -1.0000000 1.0000000 0.0000000 0.0000000
cyl8:am1 1.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 1.0000000

4 changes: 2 additions & 2 deletions tests/testthat/_snaps/data_rescale.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Code
head(rescale(iris, to = c(0, 1)))
Message <simpleMessage>
Message
Variables of class `factor` can't be rescaled and remain unchanged.
Output
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
Expand Down Expand Up @@ -30,7 +30,7 @@

Code
head(rescale(iris, to = list(Sepal.Length = c(0, 1), Petal.Length = c(-1, 0))))
Message <simpleMessage>
Message
Variables of class `factor` can't be rescaled and remain unchanged.
Output
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/data_separate.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@

Code
data_separate(d_sep, guess_columns = "mode", select = NULL)
Message <simpleMessage>
Message
Column `x` had different number of values after splitting. Variable was
split into 3 columns.
`x` returned more columns than expected after splitting. Right-most
Expand Down
8 changes: 5 additions & 3 deletions tests/testthat/test-data_read.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
skip_on_cran()
skip_if_offline()

skip_if_not_installed("httr")
skip_if_not_installed("readxl")
skip_if_not_installed("haven")
skip_if_not_installed("readr")
skip_if_not_installed("data.table")
skip_if_not_installed("rio")

skip_on_cran()

skip_if_not_installed("curl")
skip_if_offline()

# csv -------------------------

test_that("data_read - csv", {
Expand Down
8 changes: 5 additions & 3 deletions tests/testthat/test-data_to_factor.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# numeric, partially labelled
test_that("to_factor", {
x <- c(10, 11, 12)
attr(x, "labels") <- c("ten" = 10, "twelve" = 12)

Check warning on line 25 in tests/testthat/test-data_to_factor.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-data_to_factor.R,line=25,col=26,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).

Check warning on line 25 in tests/testthat/test-data_to_factor.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-data_to_factor.R,line=25,col=38,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
expect_message(
expect_identical(
to_factor(x),
Expand Down Expand Up @@ -82,12 +82,14 @@

# SPSS file, many value labels -----------------------------------

skip_on_cran()
skip_if_offline()

skip_if_not_installed("httr")
skip_if_not_installed("haven")

skip_on_cran()

skip_if_not_installed("curl")
skip_if_offline()

# Output validated against SPSS output from original dataset

test_that("data_read, convert many labels correctly", {
Expand Down
8 changes: 5 additions & 3 deletions tests/testthat/test-data_write.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
skip_on_cran()
skip_if_offline()

skip_if_not_installed("httr")
skip_if_not_installed("haven")
skip_if_not_installed("readr")

skip_on_cran()

skip_if_not_installed("curl")
skip_if_offline()

# prepare data set ---------------

data(efc)
Expand Down
Loading