mark/expression: allow forwardslash characters in identifiers

This commit is contained in:
Alexander King 2021-10-29 09:47:44 -04:00
parent f96c0a6bd4
commit 7479c6a549
4 changed files with 5 additions and 4 deletions

View File

@ -0,0 +1,2 @@
The test selection options ``pytest -k`` and ``pytest -m`` now support matching
names containing forwardslash (``\/``)characters.

View File

@ -6,7 +6,7 @@ expression: expr? EOF
expr: and_expr ('or' and_expr)*
and_expr: not_expr ('and' not_expr)*
not_expr: 'not' not_expr | '(' expr ')' | ident
ident: (\w|:|\+|-|\.|\[|\]|\\)+
ident: (\w|:|\+|-|\.|\[|\]|\\|\/)+
The semantics are:
@ -88,7 +88,7 @@ class Scanner:
yield Token(TokenType.RPAREN, ")", pos)
pos += 1
else:
match = re.match(r"(:?\w|:|\+|-|\.|\[|\]|\\)+", input[pos:])
match = re.match(r"(:?\w|:|\+|-|\.|\[|\]|\\|\/)+", input[pos:])
if match:
value = match.group(0)
if value == "or":

View File

@ -1112,7 +1112,7 @@ def test_pytest_param_id_allows_none_or_string(s) -> None:
assert pytest.param(id=s)
@pytest.mark.parametrize("expr", ("NOT internal_err", "NOT (internal_err)", "bogus/"))
@pytest.mark.parametrize("expr", ("NOT internal_err", "NOT (internal_err)"))
def test_marker_expr_eval_failure_handling(pytester: Pytester, expr) -> None:
foo = pytester.makepyfile(
"""

View File

@ -170,7 +170,6 @@ def test_valid_idents(ident: str) -> None:
@pytest.mark.parametrize(
"ident",
(
"/",
"^",
"*",
"=",