Skip to content

Commit 01245fb

Browse files
remove test_by_col function and its use (#741)
1 parent 2f85720 commit 01245fb

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

tests/testthat/test_registration.R

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
# There's currently an issue comparing tibbles so we do it col-by-col
2-
test_by_col <- function(a, b) {
3-
for (i in union(names(a), names(b))) {
4-
expect_equal(a[[i]], b[[i]])
5-
}
6-
}
7-
8-
# ------------------------------------------------------------------------------
9-
101
test_that('adding a new model', {
112
set_new_model("sponge")
123

@@ -21,7 +12,7 @@ test_that('adding a new model', {
2112
tibble(engine = character(0), mode = character(0))
2213
)
2314

24-
test_by_col(
15+
expect_equal(
2516
get_from_env("sponge_pkgs"),
2617
tibble(engine = character(0), pkg = list(), mode = character(0))
2718
)
@@ -30,19 +21,19 @@ expect_equal(
3021
get_from_env("sponge_modes"), "unknown"
3122
)
3223

33-
test_by_col(
24+
expect_equal(
3425
get_from_env("sponge_args"),
3526
dplyr::tibble(engine = character(0), parsnip = character(0),
3627
original = character(0), func = vector("list"),
3728
has_submodel = logical(0))
3829
)
3930

40-
test_by_col(
31+
expect_equal(
4132
get_from_env("sponge_fit"),
4233
tibble(engine = character(0), mode = character(0), value = vector("list"))
4334
)
4435

45-
test_by_col(
36+
expect_equal(
4637
get_from_env("sponge_predict"),
4738
tibble(engine = character(0), mode = character(0),
4839
type = character(0), value = vector("list"))
@@ -71,7 +62,7 @@ test_that('adding a new mode', {
7162
test_that('adding a new engine', {
7263
set_model_engine("sponge", mode = "classification", eng = "gum")
7364

74-
test_by_col(
65+
expect_equal(
7566
get_from_env("sponge"),
7667
tibble(engine = "gum", mode = "classification")
7768
)
@@ -96,20 +87,20 @@ test_that('adding a new package', {
9687
expect_error(set_dependency("sponge", "gummies", "trident"))
9788
expect_error(set_dependency("sponge", "gum", "trident", mode = "regression"))
9889

99-
test_by_col(
90+
expect_equal(
10091
get_from_env("sponge_pkgs"),
10192
tibble(engine = "gum", pkg = list("trident"), mode = "classification")
10293
)
10394

10495
set_dependency("sponge", "gum", "juicy-fruit", mode = "classification")
105-
test_by_col(
96+
expect_equal(
10697
get_from_env("sponge_pkgs"),
10798
tibble(engine = "gum",
10899
pkg = list(c("trident", "juicy-fruit")),
109100
mode = "classification")
110101
)
111102

112-
test_by_col(
103+
expect_equal(
113104
get_dependency("sponge"),
114105
tibble(engine = "gum",
115106
pkg = list(c("trident", "juicy-fruit")),
@@ -142,7 +133,7 @@ test_that('adding a new argument', {
142133
args <- get_from_env("sponge_args")
143134
expect_equal(sum(args$parsnip == "modeling"), 1)
144135

145-
test_by_col(
136+
expect_equal(
146137
get_from_env("sponge_args"),
147138
tibble(engine = "gum", parsnip = "modeling", original = "modelling",
148139
func = list(list(pkg = "foo", fun = "bar")),
@@ -267,7 +258,7 @@ test_that('adding a new fit', {
267258
)
268259

269260
fit_env_data <- get_from_env("sponge_fit")
270-
test_by_col(
261+
expect_equal(
271262
fit_env_data[ 1:2],
272263
tibble(engine = "gum", mode = "classification")
273264
)
@@ -359,7 +350,7 @@ test_that('adding a new fit', {
359350
)
360351
)
361352

362-
test_by_col(
353+
expect_equal(
363354
get_fit("sponge")[, 1:2],
364355
tibble(engine = "gum", mode = "classification")
365356
)
@@ -391,7 +382,7 @@ test_that('adding a new predict method', {
391382
)
392383

393384
pred_env_data <- get_from_env("sponge_predict")
394-
test_by_col(
385+
expect_equal(
395386
pred_env_data[ 1:3],
396387
tibble(engine = "gum", mode = "classification", type = "class")
397388
)
@@ -401,7 +392,7 @@ test_that('adding a new predict method', {
401392
class_vals
402393
)
403394

404-
test_by_col(
395+
expect_equal(
405396
get_pred_type("sponge", "class")[ 1:3],
406397
tibble(engine = "gum", mode = "classification", type = "class")
407398
)

0 commit comments

Comments
 (0)