From 4f831f68bbf6020430e014b81ac5c88e9702b861 Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Thu, 4 May 2023 16:06:56 +0200 Subject: [PATCH 1/2] Set stringsAsFactors to FALSE in data.frame conversions --- r/tests/testthat/helper-expectation.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/tests/testthat/helper-expectation.R b/r/tests/testthat/helper-expectation.R index 090ed36aa7f..f8c150c53e7 100644 --- a/r/tests/testthat/helper-expectation.R +++ b/r/tests/testthat/helper-expectation.R @@ -21,7 +21,7 @@ expect_as_vector <- function(x, y, ...) { # expect both objects to contain equal values when converted to data.frame objects expect_equal_data_frame <- function(x, y, ...) { - expect_equal(as.data.frame(x), as.data.frame(y), ...) + expect_equal(as.data.frame(x, stringsAsFactors = FALSE), as.data.frame(y, stringsAsFactors = FALSE), ...) } expect_r6_class <- function(object, class) { From aea791488d116788eac90447b58c64259bc9c1b6 Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Thu, 4 May 2023 16:49:48 +0200 Subject: [PATCH 2/2] Move stringsAsFactors=FALSE to where needed --- r/tests/testthat/helper-expectation.R | 2 +- r/tests/testthat/test-dataset-csv.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/r/tests/testthat/helper-expectation.R b/r/tests/testthat/helper-expectation.R index f8c150c53e7..090ed36aa7f 100644 --- a/r/tests/testthat/helper-expectation.R +++ b/r/tests/testthat/helper-expectation.R @@ -21,7 +21,7 @@ expect_as_vector <- function(x, y, ...) { # expect both objects to contain equal values when converted to data.frame objects expect_equal_data_frame <- function(x, y, ...) { - expect_equal(as.data.frame(x, stringsAsFactors = FALSE), as.data.frame(y, stringsAsFactors = FALSE), ...) + expect_equal(as.data.frame(x), as.data.frame(y), ...) } expect_r6_class <- function(object, class) { diff --git a/r/tests/testthat/test-dataset-csv.R b/r/tests/testthat/test-dataset-csv.R index 98858a7d166..db1ce20ace9 100644 --- a/r/tests/testthat/test-dataset-csv.R +++ b/r/tests/testthat/test-dataset-csv.R @@ -91,7 +91,7 @@ test_that("CSV scan options", { sb$FragmentScanOptions(options) tab <- sb$Finish()$ToTable() - expect_equal_data_frame(tab, data.frame(chr = c("foo", NA))) + expect_equal_data_frame(tab, data.frame(chr = c("foo", NA), stringsAsFactors = FALSE)) # Set default convert options in CsvFileFormat csv_format <- CsvFileFormat$create(