From 778ec9bed6d8506e6eaf6bd9d167f47d9daef8ba Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Tue, 24 May 2022 09:20:11 -0700 Subject: [PATCH] Use `expect_null()` where appropriate in tests (#6211) --- tests/testthat/test-count-tally.r | 2 +- tests/testthat/test-nth-value.R | 4 ++-- tests/testthat/test-summarise.r | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-count-tally.r b/tests/testthat/test-count-tally.r index f404f4ebd4..54cc7b6179 100644 --- a/tests/testthat/test-count-tally.r +++ b/tests/testthat/test-count-tally.r @@ -55,7 +55,7 @@ test_that("output preserves class & attributes where possible", { expect_s3_class(out, "grouped_df") expect_equal(group_vars(out), "g") # summarise() currently drops attributes - expect_equal(attr(out, "my_attr"), NULL) + expect_null(attr(out, "my_attr")) }) test_that("works with dbplyr", { diff --git a/tests/testthat/test-nth-value.R b/tests/testthat/test-nth-value.R index e21b913140..9ec9fe1734 100644 --- a/tests/testthat/test-nth-value.R +++ b/tests/testthat/test-nth-value.R @@ -2,7 +2,7 @@ test_that("nth works with lists", { x <- list(1, 2, 3) expect_equal(nth(x, 1), 1) - expect_equal(nth(x, 4), NULL) + expect_null(nth(x, 4)) expect_equal(nth(x, 4, default = 1), 1) }) @@ -24,7 +24,7 @@ test_that("first uses default value for 0 length vectors", { expect_equal(first(integer()), NA_integer_) expect_equal(first(numeric()), NA_real_) expect_equal(first(character()), NA_character_) - expect_equal(first(list()), NULL) + expect_null(first(list())) }) test_that("firsts uses default value for 0 length augmented vectors", { diff --git a/tests/testthat/test-summarise.r b/tests/testthat/test-summarise.r index c493c3d9d5..425cd1615e 100644 --- a/tests/testthat/test-summarise.r +++ b/tests/testthat/test-summarise.r @@ -66,11 +66,11 @@ test_that("preserved class, but not attributes", { out <- df %>% summarise(n = n()) expect_s3_class(out, "data.frame", exact = TRUE) - expect_equal(attr(out, "res"), NULL) + expect_null(attr(out, "res")) out <- df %>% group_by(g1) %>% summarise(n = n()) # expect_s3_class(out, "data.frame", exact = TRUE) - expect_equal(attr(out, "res"), NULL) + expect_null(attr(out, "res")) }) test_that("works with unquoted values", {