Skip to content

Commit 8b6491f

Browse files
sun-ruishivaram
authored andcommitted
[SPARK-15091][SPARKR] Fix warnings and a failure in SparkR test cases with testthat version 1.0.1
## What changes were proposed in this pull request? Fix warnings and a failure in SparkR test cases with testthat version 1.0.1 ## How was this patch tested? SparkR unit test cases. Author: Sun Rui <sunrui2016@gmail.com> Closes apache#12867 from sun-rui/SPARK-15091.
1 parent d26f7cb commit 8b6491f

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

R/pkg/inst/tests/testthat/test_client.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test_that("no package specified doesn't add packages flag", {
3232
})
3333

3434
test_that("multiple packages don't produce a warning", {
35-
expect_that(generateSparkSubmitArgs("", "", "", "", c("A", "B")), not(gives_warning()))
35+
expect_warning(generateSparkSubmitArgs("", "", "", "", c("A", "B")), NA)
3636
})
3737

3838
test_that("sparkJars sparkPackages as character vectors", {

R/pkg/inst/tests/testthat/test_context.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ test_that("sparkJars sparkPackages as comma-separated strings", {
138138

139139
# check normalizePath
140140
f <- dir()[[1]]
141-
expect_that(processSparkJars(f), not(gives_warning()))
141+
expect_warning(processSparkJars(f), NA)
142142
expect_match(processSparkJars(f), f)
143143
})
144144

R/pkg/inst/tests/testthat/test_mllib.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ test_that("spark.survreg", {
450450
if (requireNamespace("survival", quietly = TRUE)) {
451451
rData <- list(time = c(4, 3, 1, 1, 2, 2, 3), status = c(1, 1, 1, 0, 1, 1, 0),
452452
x = c(0, 2, 1, 1, 1, 0, 0), sex = c(0, 0, 0, 0, 1, 1, 1))
453-
expect_that(
453+
expect_error(
454454
model <- survival::survreg(formula = survival::Surv(time, status) ~ x + sex, data = rData),
455-
not(throws_error()))
455+
NA)
456456
expect_equal(predict(model, rData)[[1]], 3.724591, tolerance = 1e-4)
457457
}
458458
})

R/pkg/inst/tests/testthat/test_sparkSQL.R

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,9 @@ test_that("date functions on a DataFrame", {
11961196
c(as.POSIXlt("2012-12-13 21:34:00 UTC"), as.POSIXlt("2014-12-15 10:24:34 UTC")))
11971197
expect_equal(collect(select(df2, to_utc_timestamp(df2$b, "JST")))[, 1],
11981198
c(as.POSIXlt("2012-12-13 03:34:00 UTC"), as.POSIXlt("2014-12-14 16:24:34 UTC")))
1199-
expect_more_than(collect(select(df2, unix_timestamp()))[1, 1], 0)
1200-
expect_more_than(collect(select(df2, unix_timestamp(df2$b)))[1, 1], 0)
1201-
expect_more_than(collect(select(df2, unix_timestamp(lit("2015-01-01"), "yyyy-MM-dd")))[1, 1], 0)
1199+
expect_gt(collect(select(df2, unix_timestamp()))[1, 1], 0)
1200+
expect_gt(collect(select(df2, unix_timestamp(df2$b)))[1, 1], 0)
1201+
expect_gt(collect(select(df2, unix_timestamp(lit("2015-01-01"), "yyyy-MM-dd")))[1, 1], 0)
12021202

12031203
l3 <- list(list(a = 1000), list(a = -1000))
12041204
df3 <- createDataFrame(sqlContext, l3)
@@ -1502,15 +1502,14 @@ test_that("toJSON() returns an RDD of the correct values", {
15021502

15031503
test_that("showDF()", {
15041504
df <- read.json(sqlContext, jsonPath)
1505-
s <- capture.output(showDF(df))
15061505
expected <- paste("+----+-------+\n",
15071506
"| age| name|\n",
15081507
"+----+-------+\n",
15091508
"|null|Michael|\n",
15101509
"| 30| Andy|\n",
15111510
"| 19| Justin|\n",
15121511
"+----+-------+\n", sep = "")
1513-
expect_output(s, expected)
1512+
expect_output(showDF(df), expected)
15141513
})
15151514

15161515
test_that("isLocal()", {
@@ -1896,7 +1895,7 @@ test_that("Method as.data.frame as a synonym for collect()", {
18961895
expect_equal(as.data.frame(irisDF2), collect(irisDF2))
18971896

18981897
# Make sure as.data.frame in the R base package is not covered
1899-
expect_that(as.data.frame(c(1, 2)), not(throws_error()))
1898+
expect_error(as.data.frame(c(1, 2)), NA)
19001899
})
19011900

19021901
test_that("attach() on a DataFrame", {

0 commit comments

Comments
 (0)