MCPcopy
hub / github.com/pytest-dev/pytest / test_backslash_not_treated_specially

Function test_backslash_not_treated_specially

testing/test_mark_expression.py:73–86  ·  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

71
72
73def test_backslash_not_treated_specially() -> None:
74 r"""When generating nodeids, if the source name contains special characters
75 like a newline, they are escaped into two characters like \n. Therefore, a
76 user will never need to insert a literal newline, only \n (two chars). So
77 mark expressions themselves do not support escaping, instead they treat
78 backslashes as regular identifier characters."""
79
80 def matcher(name: str, /, **kwargs: str | int | bool | None) -> bool:
81 return {r"\nfoo\n"}.__contains__(name)
82
83 assert evaluate(r"\nfoo\n", matcher)
84 assert not evaluate(r"foo", matcher)
85 with pytest.raises(SyntaxError):
86 evaluate("\nfoo\n", matcher)
87
88
89def test_backslash_in_identifier_with_string_literal() -> None:

Callers

nothing calls this directly

Calls 1

evaluateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…