Problem
When collecting tests that have parametrized values containing escaped unicode (like "\\u2603"), rtest generates different test IDs than pytest, causing pytest to fail with "not found" errors when using --runner pytest.
Reproduction
Given this test:
@pytest.mark.parametrize(
"test_value,expected", [(True, '"\\u2603"'), (False, '"\u2603"')]
)
def test_json_as_unicode(test_value, expected, app, app_ctx):
app.json.ensure_ascii = test_value
rv = app.json.dumps("\N{SNOWMAN}")
assert rv == expected
pytest generates test IDs:
test_json_as_unicode[True-"\\u2603"]
test_json_as_unicode[False-"\u2603"]
But rtest generates different IDs (likely without the proper escaping), causing:
ERROR: not found: tests/test_json.py::test_json_as_unicode
(no match in any of [<Module test_json.py>])
This happens on real-world projects like Flask's tests/test_json.py.
Context
The issue seems to be in how we serialize string literals containing backslash escapes when generating test IDs. The source string '"\\u2603"' contains a literal backslash followed by u2603, which pytest preserves verbatim in the test ID, but rtest may be handling the escaping differently.
Problem
When collecting tests that have parametrized values containing escaped unicode (like
"\\u2603"), rtest generates different test IDs than pytest, causing pytest to fail with "not found" errors when using--runner pytest.Reproduction
Given this test:
pytest generates test IDs:
test_json_as_unicode[True-"\\u2603"]test_json_as_unicode[False-"\u2603"]But rtest generates different IDs (likely without the proper escaping), causing:
This happens on real-world projects like Flask's
tests/test_json.py.Context
The issue seems to be in how we serialize string literals containing backslash escapes when generating test IDs. The source string
'"\\u2603"'contains a literal backslash followed byu2603, which pytest preserves verbatim in the test ID, but rtest may be handling the escaping differently.