MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_backslash_not_treated_specially

Function test_backslash_not_treated_specially

testing/test_mark_expression.py:69–80  ·  view source on GitHub ↗

r"""When generating nodeids, if the source name contains special characters like a newline, they are escaped into two characters like \n. Therefore, a user will never need to insert a literal newline, only \n (two chars). So mark expressions themselves do not support escaping, instead th

()

Source from the content-addressed store, hash-verified

67
68
69def test_backslash_not_treated_specially() -> None:
70 r"""When generating nodeids, if the source name contains special characters
71 like a newline, they are escaped into two characters like \n. Therefore, a
72 user will never need to insert a literal newline, only \n (two chars). So
73 mark expressions themselves do not support escaping, instead they treat
74 backslashes as regular identifier characters."""
75 matcher = {r"\nfoo\n"}.__contains__
76
77 assert evaluate(r"\nfoo\n", matcher)
78 assert not evaluate(r"foo", matcher)
79 with pytest.raises(ParseError):
80 evaluate("\nfoo\n", matcher)
81
82
83@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

evaluateFunction · 0.85

Tested by

no test coverage detected