Skip to content

Commit

Permalink
options for strict tests; few enhancements (#626)
Browse files Browse the repository at this point in the history
- part of
insightsengineering/coredev-tasks#498
- part of
insightsengineering/coredev-tasks#478
- please read this for more info about the implementation:
insightsengineering/coredev-tasks#478 (comment)
- removed `pkg::` from examples for packages in Depends
- reoredered rd tags to have examples at the bottom
- fix roxygen warning about documenting package level Rd file
- removed `# nolint` from code-docs (e.g. examples or knitr chunks)
(this is actually rendered!). I needed to put a higher level exclusion
in the top `.lintr` file. This is of course more powerful than single
line (or code-bloc) exclusions
- reviewed `dontrun{}`
- removed `teal.modules.general::` from examples and vignettes as this
is actually redundant here

Please review the changes carefully and let me know if there is
something you don't like.

---------

Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: vedhav <[email protected]>
Co-authored-by: Vedha Viyash <[email protected]>
  • Loading branch information
4 people authored Mar 18, 2024
1 parent dff3e33 commit 18978fb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ Suggests:
rlang (>= 1.0.0),
rtables (>= 0.6.6),
sparkline,
testthat (>= 3.0.4)
testthat (>= 3.0.4),
withr (>= 2.0.0)
VignetteBuilder:
knitr
Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2,
Expand All @@ -89,7 +90,7 @@ Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2,
jeroen/jsonlite, yihui/knitr, deepayan/lattice, MASS,
insightsengineering/nestcolor, r-lib/rlang,
insightsengineering/rtables, sparkline, insightsengineering/teal.data,
r-lib/testthat
r-lib/testthat, r-lib/withr
Config/Needs/website: insightsengineering/nesttemplate
Encoding: UTF-8
Language: en-US
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/setup-logger.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logger::log_appender(function(...) NULL, namespace = "teal.modules.general")
20 changes: 20 additions & 0 deletions tests/testthat/setup-options.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# `opts_partial_match_old` is left for exclusions due to partial matching in dependent packages (i.e. not fixable here)
# it might happen that it is not used right now, but it is left for possible future use
# use with: `withr::with_options(opts_partial_match_old, { ... })` inside the test
opts_partial_match_old <- list(
warnPartialMatchDollar = getOption("warnPartialMatchDollar"),
warnPartialMatchArgs = getOption("warnPartialMatchArgs"),
warnPartialMatchAttr = getOption("warnPartialMatchAttr")
)
opts_partial_match_new <- list(
warnPartialMatchDollar = TRUE,
warnPartialMatchArgs = TRUE,
warnPartialMatchAttr = TRUE
)

if (isFALSE(getFromNamespace("on_cran", "testthat")()) && requireNamespace("withr", quietly = TRUE)) {
withr::local_options(
opts_partial_match_new,
.local_envir = testthat::teardown_env()
)
}
10 changes: 5 additions & 5 deletions tests/testthat/test-tm_g_bivariate.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ testthat::test_that("tm_g_bivariate creates a `teal_module` object", {
row_facet = mock_data_extract_spec(select_multiple = FALSE),
col_facet = mock_data_extract_spec(select_multiple = FALSE),
facet = TRUE,
color_setting = TRUE,
color_settings = TRUE,
use_density = TRUE,
free_x_scales = TRUE,
free_y_scales = TRUE,
Expand Down Expand Up @@ -229,7 +229,7 @@ testthat::test_that("tm_g_bivariate fails when `color_setting` is FALSE and `col
"a label",
mock_data_extract_spec(select_multiple = FALSE),
mock_data_extract_spec(select_multiple = FALSE),
color_setting = FALSE,
color_settings = FALSE,
color = mock_data_extract_spec()
),
"'color_settings' argument needs to be set to TRUE if 'color', 'fill', and/or 'size' is/are supplied."
Expand All @@ -244,7 +244,7 @@ testthat::test_that("tm_g_bivariate fails when `color_setting` is FALSE and `siz
"a label",
mock_data_extract_spec(select_multiple = FALSE),
mock_data_extract_spec(select_multiple = FALSE),
color_setting = FALSE,
color_settings = FALSE,
size = mock_data_extract_spec()
),
"'color_settings' argument needs to be set to TRUE if 'color', 'fill', and/or 'size' is/are supplied."
Expand All @@ -259,7 +259,7 @@ testthat::test_that("tm_g_bivariate fails when `color_setting` is FALSE and `fil
"a label",
mock_data_extract_spec(select_multiple = FALSE),
mock_data_extract_spec(select_multiple = FALSE),
color_setting = FALSE,
color_settings = FALSE,
fill = mock_data_extract_spec()
),
"'color_settings' argument needs to be set to TRUE if 'color', 'fill', and/or 'size' is/are supplied."
Expand All @@ -273,7 +273,7 @@ testthat::test_that("tm_g_bivariate determines `color`, `size` and `fill` when `
"a label",
mock_data_extract_spec(select_multiple = FALSE),
mock_data_extract_spec(select_multiple = FALSE),
color_setting = TRUE
color_settings = TRUE
)

testthat::expect_contains(
Expand Down
8 changes: 4 additions & 4 deletions vignettes/teal-modules-general.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ library(teal.widgets)
# teal_data object
data <- teal_data()
data <- within(data, {
ADSL <- teal.modules.general::rADSL
ADTTE <- teal.modules.general::rADTTE
ADSL <- rADSL
ADTTE <- rADTTE
})
datanames <- c("ADSL", "ADTTE")
datanames(data) <- datanames
Expand Down Expand Up @@ -91,8 +91,8 @@ Following this, we set the `datanames` and `join_keys`.
```r
data <- teal_data()
data <- within(data, {
ADSL <- teal.modules.general::rADSL
ADTTE <- teal.modules.general::rADTTE
ADSL <- rADSL
ADTTE <- rADTTE
})
datanames <- c("ADSL", "ADTTE")
datanames(data) <- datanames
Expand Down

0 comments on commit 18978fb

Please sign in to comment.