Skip to content

Tests fail due to locale-dependent smart quotes in error message matching (fixed = TRUE) #653

@villegar

Description

@villegar

Summary

Some tests fail when running with Armadillo (and certain R/locale configurations) because error messages use Unicode smart quotes (‘ ’) instead of ASCII single quotes ('), causing strict expect_error(..., fixed = TRUE) comparisons to fail even though the correct error is thrown.

Failing Test Example

expect_error(
  datashield.aggregate(conns = NULL, expr = calltext),
  "unable to find an inherited method for function 'dsIsAsync' for signature 'conn = \"NULL\"'",
  fixed = TRUE
)

Observed failure:

  • Expected: 'dsIsAsync'
  • Actual: ‘dsIsAsync’

Error message received:

unable to find an inherited method for function ‘dsIsAsync’ for signature ‘conn = "NULL"’

Root Cause

The difference is purely typographical:

  • ASCII quotes: '
  • Unicode smart quotes: ‘ ’

This variation depends on:

  • R version
  • system locale (e.g. UTF-8 vs C)
  • platform/container environment
  • upstream package message formatting (S4 dispatch errors)

Since the test uses fixed = TRUE, it performs an exact byte match and fails despite the semantic message being identical.

Why This Is Problematic

  1. Makes tests locale-dependent and non-portable
  2. Causes false negatives in CI and Docker environments
  3. Fails on systems that default to UTF-8 smart quotes
  4. The underlying functionality is correct, but the test is overly strict

Suggested Fix

Replace strict fixed-string matching with a more robust pattern, for example:

expect_error(
  datashield.aggregate(conns = NULL, expr = calltext),
  "dsIsAsync"
)

or remove fixed = TRUE and match a stable substring.

Alternatively:

  • Normalise quotes before comparison, or
  • Avoid matching the full error string from S4 dispatch (which is not guaranteed to be stable across R builds)

Environment Where Observed

  • Backend: ArmadilloDriver
  • Docker-based test environment
  • UTF-8 locale
  • R producing Unicode curly quotes in S4 error messages

Workaround

Setting locale to C avoids the issue:

Sys.setlocale("LC_ALL", "C")

However, tests should ideally be locale-agnostic rather than requiring environment-specific configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions