From dd5719695376b19c2ad9db0789a08f459ad7c9fb Mon Sep 17 00:00:00 2001 From: lovetheguitar Date: Sat, 22 Jun 2024 20:44:50 +0200 Subject: [PATCH] perf(expression): define `TokenType.STRING` as "string literal" for clearer errors --- src/_pytest/mark/expression.py | 2 +- testing/test_mark_expression.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/_pytest/mark/expression.py b/src/_pytest/mark/expression.py index 0daaaf22f..ce98e9c7e 100644 --- a/src/_pytest/mark/expression.py +++ b/src/_pytest/mark/expression.py @@ -51,7 +51,7 @@ class TokenType(enum.Enum): IDENT = "identifier" EOF = "end of input" EQUAL = "=" - STRING = "str" + STRING = "string literal" COMMA = "," diff --git a/testing/test_mark_expression.py b/testing/test_mark_expression.py index c31ab4470..b5f1f330a 100644 --- a/testing/test_mark_expression.py +++ b/testing/test_mark_expression.py @@ -228,6 +228,7 @@ def test_invalid_idents(ident: str) -> None: r'escaping with "\\" not supported in marker expression', ), ("mark(empty_list=[])", r'unexpected character/s "\[\]"'), + ("'str'", "expected not OR left parenthesis OR identifier; got string literal"), ), ) def test_invalid_kwarg_name_or_value( # TODO: move to `test_syntax_errors` ?