Skip to content

Commit

Permalink
skip before require (#931)
Browse files Browse the repository at this point in the history
follow up on
https://github.com/insightsengineering/rtables/pull/928/files

execute skip before any require
  • Loading branch information
pawelru authored Sep 6, 2024
1 parent 35fe5cd commit 475b452
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/testthat/test-as_html.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ test_that("as_html indentation is translated to rows with linebreaks", {
})

test_that("as_html expands or not newlines depending on expand_newlines", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")
require(dplyr, quietly = TRUE)

# Table with both col/row names with newlines
iris_mod <- iris %>%
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-formatting.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ test_that("format_na_str functionality works in get_formatted_cells (i.e. printi
})

test_that("format and na_str inheritance", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")
require(dplyr, quietly = TRUE)

# Test data
DM2 <- DM %>%
Expand Down Expand Up @@ -166,8 +166,8 @@ test_that("format and na_str inheritance", {
# Get the ASCII table
result <- get_formatted_cells(tbl) # Main function

require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")
require(dplyr, quietly = TRUE)

# Expected data-set is built with dplyr
expected <- DM2 %>%
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-printing.R
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ test_that("Cell and column label wrapping works in printing", {


test_that("row label indentation is kept even if there are newline characters", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")
require(dplyr, quietly = TRUE)

ANL <- DM %>%
mutate(value = rnorm(n()), pctdiff = runif(n())) %>%
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-tab_afun_cfun.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
context("Analysis functions (afun)")

test_that(".spl_context contains information about the column split", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")
require(dplyr, quietly = TRUE)

## Duplication hack -> This would need to use split_cols_by_multivar(...)
# Workaround for #690
Expand Down Expand Up @@ -42,11 +42,11 @@ test_that(".spl_context contains information about the column split", {
})

test_that(".spl_context and afun extra parameters contain information about combo counts", {
require(tibble, quietly = TRUE)
skip_if_not_installed("tibble")
require(tibble, quietly = TRUE)

require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")
require(dplyr, quietly = TRUE)

## Fix for https://github.com/insightsengineering/rtables/issues/517
combodf <- tribble(
Expand Down Expand Up @@ -226,8 +226,8 @@ test_that("Error localization for missing split variable when done in alt_count_
})

test_that("Error localization for missmatch split variable when done in alt_count_df", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")
require(dplyr, quietly = TRUE)

afun_tmp <- function(x, .alt_df_row, .spl_context, ...) {
# Important check that order is aligned even if source levels are not
Expand Down Expand Up @@ -293,8 +293,8 @@ test_that("Error localization for missmatch split variable when done in alt_coun
context("Content functions (cfun)")

test_that(".alt_df_row appears in cfun but not in afun.", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")
require(dplyr, quietly = TRUE)

# Adding STRATA2 col to DM for alt_counts_df col split
alt_tmp <- DM %>% left_join(
Expand Down

0 comments on commit 475b452

Please sign in to comment.