Skip to content

Commit

Permalink
fix tests errors, add tests/testthat/helper-state.R
Browse files Browse the repository at this point in the history
  • Loading branch information
rempsyc committed Nov 5, 2023
1 parent 8057864 commit 40d3080
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 8 additions & 2 deletions R/report.htest.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ report_effectsize.htest <- function(x, ...) {

if (grepl("Friedman", attributes(x$statistic)$names, fixed = TRUE)) {
out <- .report_effectsize_friedman(x, table, dot_args)
} else if (grepl("Kruskal", attributes(x$statistic)$names, fixed = TRUE)) {
} else if (!is.null(x$statistic) && grepl(
"Kruskal", attributes(x$statistic)$names,
fixed = TRUE
)) {
# For Kruskal-Wallis test ---------------

out <- .report_effectsize_kruskal(x, table, dot_args)
Expand Down Expand Up @@ -266,7 +269,10 @@ report_parameters.htest <- function(x, table = NULL, ...) {
model_info$is_ranktest &&
grepl("Friedman", attributes(x$statistic)$names, fixed = TRUE)) {
out <- .report_parameters_friedman(table, stats, effsize, ...)
} else if (grepl("Kruskal", attributes(x$statistic)$names, fixed = TRUE)) {
} else if (!is.null(x$statistic) && grepl(
"Kruskal", attributes(x$statistic)$names,
fixed = TRUE
)) {
# Kruskal
out <- .report_parameters_kruskal(table, stats, effsize, ...)
# chi2
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/helper-state.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
testthat::set_state_inspector(function() {
list(
attached = search(),
connections = nrow(showConnections()),
cwd = getwd(),
envvars = Sys.getenv(),
libpaths = .libPaths(),
locale = Sys.getlocale(),
options = .Options,
packages = .packages(all.available = TRUE),
NULL
)
})

Check warning on line 13 in tests/testthat/helper-state.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/helper-state.R,line=13,col=3,[trailing_blank_lines_linter] Missing terminal newline.

0 comments on commit 40d3080

Please sign in to comment.