From d24091a6692c90fb6ff46b7dbb91fbbed2b14eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sat, 4 Nov 2023 11:11:08 +0100 Subject: [PATCH] usethis::use_testthat(3) --- DESCRIPTION | 3 ++- tests/testthat.R | 8 ++++++++ tests/testthat/test-bytes.r | 3 --- tests/testthat/test-color.r | 2 -- tests/testthat/test-ms.r | 7 ------- tests/testthat/test-numbers.r | 3 --- tests/testthat/test-p-value.r | 2 -- tests/testthat/test-rounding.r | 2 -- tests/testthat/test-vague-dt.r | 3 --- 9 files changed, 10 insertions(+), 23 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fc19b49..6f96e9a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,8 +22,9 @@ Depends: Suggests: codetools, covr, - testthat + testthat (>= 3.0.0) RoxygenNote: 7.2.3 Roxygen: list(markdown = TRUE) Encoding: UTF-8 Config/Needs/website: tidyverse/tidytemplate +Config/testthat/edition: 3 diff --git a/tests/testthat.R b/tests/testthat.R index a6bbded..501166e 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,3 +1,11 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + library(testthat) library(prettyunits) diff --git a/tests/testthat/test-bytes.r b/tests/testthat/test-bytes.r index 9212183..d83e07b 100644 --- a/tests/testthat/test-bytes.r +++ b/tests/testthat/test-bytes.r @@ -1,6 +1,3 @@ - -context("Pretty bytes") - test_that("sizes.R is standalone", { stenv <- environment(format_bytes$pretty_bytes) objs <- ls(stenv, all.names = TRUE) diff --git a/tests/testthat/test-color.r b/tests/testthat/test-color.r index 0013aee..98d3798 100644 --- a/tests/testthat/test-color.r +++ b/tests/testthat/test-color.r @@ -1,5 +1,3 @@ -context("Pretty color") - test_that("pretty_color works", { expect_equal( pretty_color("black"), diff --git a/tests/testthat/test-ms.r b/tests/testthat/test-ms.r index 365eb7f..2e62a32 100644 --- a/tests/testthat/test-ms.r +++ b/tests/testthat/test-ms.r @@ -1,6 +1,3 @@ - -context("Pretty milliseconds") - test_that("pretty_ms works", { expect_equal(pretty_ms(0), '0ms') @@ -36,8 +33,6 @@ test_that("pretty_ms handles vectors", { expect_equal(pretty_ms(v), v2) }) -context("Pretty seconds") - test_that("pretty_sec works", { expect_equal(pretty_sec(0 / 1000), '0ms') @@ -73,8 +68,6 @@ test_that("pretty_sec handles vectors", { expect_equal(pretty_sec(v), v2) }) -context("Pretty dt") - test_that("pretty_dt works", { expect_equal(pretty_dt(as.difftime(units = "secs", 0 / 1000)), '0ms') diff --git a/tests/testthat/test-numbers.r b/tests/testthat/test-numbers.r index 88e9f20..5d4878f 100644 --- a/tests/testthat/test-numbers.r +++ b/tests/testthat/test-numbers.r @@ -1,6 +1,3 @@ - -context("Pretty numbers") - test_that("sizes.R is standalone", { stenv <- environment(format_num$pretty_num) objs <- ls(stenv, all.names = TRUE) diff --git a/tests/testthat/test-p-value.r b/tests/testthat/test-p-value.r index 67a4ff3..509a913 100644 --- a/tests/testthat/test-p-value.r +++ b/tests/testthat/test-p-value.r @@ -1,5 +1,3 @@ -context("p-values") - test_that("p-values work", { expect_equal( pretty_p_value(c(1, 0, NA, 0.01, 0.0000001)), diff --git a/tests/testthat/test-rounding.r b/tests/testthat/test-rounding.r index 565f7ea..5d03841 100644 --- a/tests/testthat/test-rounding.r +++ b/tests/testthat/test-rounding.r @@ -1,5 +1,3 @@ -context("Rounding to string values") - test_that("Rounding", { expect_error(pretty_round(1, c(2, 3)), regexp="digits must either be a scalar or the same length as x") diff --git a/tests/testthat/test-vague-dt.r b/tests/testthat/test-vague-dt.r index f0cd789..771cb1c 100644 --- a/tests/testthat/test-vague-dt.r +++ b/tests/testthat/test-vague-dt.r @@ -1,6 +1,3 @@ - -context("Vague time intervals") - ## Amount, unit, default result, short, terse all_tests <- list( list( 1, "secs", "moments ago", "<1 min", " 1s"),