From f18ed1e532c7b6863a3464af86928eb86078ae03 Mon Sep 17 00:00:00 2001
From: Daniel <mail@danielluedecke.de>
Date: Sun, 20 Oct 2024 14:02:24 +0200
Subject: [PATCH] don't use special char

---
 tests/testthat/test-pretty_names.R | 51 ++++++++++++++++--------------
 1 file changed, 28 insertions(+), 23 deletions(-)

diff --git a/tests/testthat/test-pretty_names.R b/tests/testthat/test-pretty_names.R
index 53902f51e..5496b56d0 100644
--- a/tests/testthat/test-pretty_names.R
+++ b/tests/testthat/test-pretty_names.R
@@ -34,29 +34,34 @@ test_that("pretty_names", {
   )
 })
 
+skip_if_not_installed("withr")
 
-test_that("pretty_labels", {
-  set.seed(1024)
-  N <- 5000
-  X <- rbinom(N, 1, .5)
-  M <- sample(c("a", "b", "c"), N, replace = TRUE)
-  b <- runif(8, -1, 1)
-  Y <- rbinom(N, 1, prob = plogis(
-    b[1] + b[2] * X +
-    b[3] * (M == "b") + b[4] * (M == "b") + b[5] * (M == "c") +
-    b[6] * X * (M == "a") + b[7] * X + (M == "b") +
-    b[8] * X * (M == "c")
-  ))
-  dat <- data.frame(Y, X, M, stringsAsFactors = FALSE)
-  mod <- glm(Y ~ X * M, data = dat, family = binomial)
+# make sure we have the correct interaction mark for tests
+withr::with_options(
+  list(parameters_interaction = "*"),
+  test_that("pretty_labels", {
+    set.seed(1024)
+    N <- 5000
+    X <- rbinom(N, 1, .5)
+    M <- sample(c("a", "b", "c"), N, replace = TRUE)
+    b <- runif(8, -1, 1)
+    Y <- rbinom(N, 1, prob = plogis(
+      b[1] + b[2] * X +
+      b[3] * (M == "b") + b[4] * (M == "b") + b[5] * (M == "c") +
+      b[6] * X * (M == "a") + b[7] * X + (M == "b") +
+      b[8] * X * (M == "c")
+    ))
+    dat <- data.frame(Y, X, M, stringsAsFactors = FALSE)
+    mod <- glm(Y ~ X * M, data = dat, family = binomial)
 
-  p <- parameters(mod)
-  expect_identical(
-    attr(p, "pretty_labels"),
-    c(
-      `(Intercept)` = "(Intercept)", X = "X", Mb = "M [b]", Mc = "M [c]",
-      `X:Mb` = "X × M [b]", `X:Mc` = "X × M [c]"
+    p <- parameters(mod)
+    expect_identical(
+      attr(p, "pretty_labels"),
+      c(
+        `(Intercept)` = "(Intercept)", X = "X", Mb = "M [b]", Mc = "M [c]",
+        `X:Mb` = "X * M [b]", `X:Mc` = "X * M [c]"
+      )
     )
-  )
-  expect_snapshot(print(p))
-})
+    expect_snapshot(print(p))
+  })
+)