Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options for strict tests; few enhancements #626

Merged
merged 11 commits into from
Mar 18, 2024
32 changes: 32 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,35 @@ linters: linters_with_defaults(
object_usage_linter = NULL,
object_name_linter = object_name_linter(styles = c("snake_case", "symbols"), regexes = c(ANL = "^ANL_?[0-9A-Z_]*$", ADaM = "^r?AD[A-Z]{2,3}_?[0-9]*$"))
)
exclusions: list(
"vignettes/teal-modules-general.Rmd" = list(
object_name_linter = Inf
),
"vignettes/using-association-plot.Rmd" = list(
object_name_linter = Inf
),
"vignettes/using-bivariate-plot.Rmd" = list(
object_name_linter = Inf
),
"vignettes/using-cross-table.Rmd" = list(
object_name_linter = Inf
),
"vignettes/using-data-table.Rmd" = list(
object_name_linter = Inf
),
"vignettes/using-outliers-module.Rmd" = list(
object_name_linter = Inf
),
"vignettes/using-regression-plots.Rmd" = list(
object_name_linter = Inf
),
"vignettes/using-response-plot.Rmd" = list(
object_name_linter = Inf
),
"vignettes/using-scatterplot-matrix.Rmd" = list(
object_name_linter = Inf
),
"vignettes/using-scatterplot.Rmd" = list(
object_name_linter = Inf
)
)
vedhav marked this conversation as resolved.
Show resolved Hide resolved
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()
)
}
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
Loading