-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test-qgisprocess-deprecated.R: don't suppress warnings with options() *
But use suppressWarnings() instead. Relates to CRAN review: #167 (comment).
- Loading branch information
Showing
1 changed file
with
34 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,44 @@ | ||
test_that("qgis_output() works", { | ||
withr::local_options(warn = -1) | ||
expect_error( | ||
qgis_output(list(abcde = 1), "a"), | ||
"does not inherit from class qgis_result" | ||
) | ||
qres <- structure(list(a = 1, .args = "foo"), class = "qgis_result") | ||
expect_identical(qgis_output(qres, "a"), 1) | ||
expect_identical(qgis_output(qres, 1), 1) | ||
expect_error(qgis_output(qres, "b"), "Result has no output") | ||
expect_error(qgis_output(qres, ".args"), "Result has no output") | ||
suppressWarnings({ | ||
expect_error( | ||
qgis_output(list(abcde = 1), "a"), | ||
"does not inherit from class qgis_result" | ||
) | ||
qres <- structure(list(a = 1, .args = "foo"), class = "qgis_result") | ||
expect_identical(qgis_output(qres, "a"), 1) | ||
expect_identical(qgis_output(qres, 1), 1) | ||
expect_error(qgis_output(qres, "b"), "Result has no output") | ||
expect_error(qgis_output(qres, ".args"), "Result has no output") | ||
}) | ||
}) | ||
|
||
|
||
test_that("qgis_result_single() works", { | ||
skip_if_not(has_qgis()) | ||
withr::local_options(warn = -1) | ||
suppressWarnings({ | ||
|
||
tmp_gpkg <- qgis_tmp_vector(".gpkg") | ||
tmp_gpkg2 <- qgis_tmp_vector(".gpkg") | ||
tmp_gpkg <- qgis_tmp_vector(".gpkg") | ||
tmp_gpkg2 <- qgis_tmp_vector(".gpkg") | ||
|
||
result <- qgis_run_algorithm( | ||
"native:extractbyattribute", | ||
INPUT = system.file("longlake/longlake_depth.gpkg", package = "qgisprocess"), | ||
FIELD = "WAYPOINT_I", | ||
OPERATOR = 0, | ||
VALUE = "10", | ||
OUTPUT = tmp_gpkg, | ||
FAIL_OUTPUT = tmp_gpkg2, | ||
.quiet = TRUE | ||
) | ||
result <- qgis_run_algorithm( | ||
"native:extractbyattribute", | ||
INPUT = system.file("longlake/longlake_depth.gpkg", package = "qgisprocess"), | ||
FIELD = "WAYPOINT_I", | ||
OPERATOR = 0, | ||
VALUE = "10", | ||
OUTPUT = tmp_gpkg, | ||
FAIL_OUTPUT = tmp_gpkg2, | ||
.quiet = TRUE | ||
) | ||
|
||
expect_error(qgis_result_single(result, "numeric"), "zero outputs of type") | ||
expect_identical( | ||
qgis_result_single(result, "qgis_outputVector"), | ||
result$OUTPUT | ||
) | ||
expect_identical( | ||
qgis_result_single(result), | ||
result$OUTPUT | ||
) | ||
expect_error(qgis_result_single(result, "numeric"), "zero outputs of type") | ||
expect_identical( | ||
qgis_result_single(result, "qgis_outputVector"), | ||
result$OUTPUT | ||
) | ||
expect_identical( | ||
qgis_result_single(result), | ||
result$OUTPUT | ||
) | ||
}) | ||
}) |