From 7a6d302f3b1dcc0ca08275bf9bb27f18722439ad Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 12 Dec 2024 09:10:47 -0800 Subject: [PATCH 1/2] only gsub if test is character --- R/snapshot-reporter.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/snapshot-reporter.R b/R/snapshot-reporter.R index 7f7989d6c..32743b9d9 100644 --- a/R/snapshot-reporter.R +++ b/R/snapshot-reporter.R @@ -35,7 +35,9 @@ SnapshotReporter <- R6::R6Class("SnapshotReporter", }, start_test = function(context, test) { - self$test <- gsub("\n", "", test) + if (is.character(test)) { + self$test <- gsub("\n", "", test) + } }, # Called by expectation From e8d166e4fa714dca36e62bed295a92b81e1c2775 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 12 Dec 2024 09:12:10 -0800 Subject: [PATCH 2/2] update NEWS --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index e2b1cc0a7..393e9bf88 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # testthat (development version) +* Fixed an issue where calling `skip()` outside of an active test could + cause an unexpected error (@kevinushey, #2039). + # testthat 3.2.2 ## New expectations