Skip to content

fix: escape backslashes and unicode in parametrize test IDs#125

Merged
hughhan1 merged 1 commit intomainfrom
fix/unicode-escape-test-ids
Jan 3, 2026
Merged

fix: escape backslashes and unicode in parametrize test IDs#125
hughhan1 merged 1 commit intomainfrom
fix/unicode-escape-test-ids

Conversation

@hughhan1
Copy link
Copy Markdown
Owner

@hughhan1 hughhan1 commented Jan 3, 2026

Summary

Fixes #124 - Test IDs for parametrized tests containing escaped unicode strings now match pytest's output.

Previously, strings like "\u2603" (literal backslash-u) would appear as-is in test IDs, but pytest escapes these as "\\u2603". This caused test lookups to fail when using --runner pytest.

The fix adds ascii_escape_string() which escapes:

  • Backslashes: \\\
  • Control characters: \n\n, \t\t, etc.
  • Non-ASCII: \u2603

Test plan

  • Unit tests for ascii_escape_string() function
  • Integration test comparing rtest vs pytest output
  • Manual verification with reproduction case from issue

Test IDs for parametrized tests containing escaped unicode strings now
match pytest's output. Previously, strings like `"\u2603"` (literal
backslash) would appear as-is in test IDs, but pytest escapes these
as `"\\u2603"`. This caused test lookups to fail when using `--runner pytest`.

The fix adds `ascii_escape_string()` which escapes backslashes, control
characters, and non-ASCII characters in the same way pytest does.

Fixes #124
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 3, 2026

Benchmark Comparison Report

Comparing current results against baseline from main branch.

Repository Benchmark Baseline Current Change Status
click CLI startup time 37.6ms 35.3ms -6.2% [+]
click Test discovery performance 47.5ms 46.0ms -3.2% [-]
flask CLI startup time 35.9ms 34.7ms -3.4% [-]
flask Test discovery performance 43.1ms 43.4ms +0.6% [-]
more-itertools CLI startup time 33.8ms 32.1ms -5.1% [+]
more-itertools Test discovery performance 44.3ms 43.9ms -1.0% [-]
more-itertools Test execution with native runner 2.92s 2.16s -26.0% [++]
pydantic CLI startup time 34.1ms 31.3ms -8.3% [+]
pydantic Test discovery performance 140.3ms 134.5ms -4.1% [-]

Summary

  • Total benchmarks: 9
  • Regressions (>5.0% slower): 0
  • Improvements (>5.0% faster): 4
  • No significant change: 5

Performance improvements detected!

Legend

  • [++] Significant improvement (>10.0% faster)
  • [+] Minor improvement (5.0-10.0% faster)
  • [-] No significant change (±5.0%)
  • [!] Minor regression (5.0-10.0% slower)
  • [!!] Significant regression (>10.0% slower)

@hughhan1 hughhan1 merged commit e679a95 into main Jan 3, 2026
27 checks passed
@hughhan1 hughhan1 deleted the fix/unicode-escape-test-ids branch January 3, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test ID mismatch for parametrized tests with escaped unicode strings

1 participant