Skip to content

Commit ad09f74

Browse files
committed
Fix unit test failure in Python 3.10
1 parent 350c20c commit ad09f74

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/expressions/test_interpreter_coverage4.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,17 @@ def func(a, **kwargs, b): # Non-keyword argument after **kwargs
969969
with pytest.raises(SyntaxError) as exc_info:
970970
interpreter.execute(parser.parse(code))
971971

972-
assert "arguments cannot follow var-keyword argument" in str(exc_info.value)
972+
# Python's error message for arguments after **kwargs varies by version:
973+
# - Python <= 3.10: "invalid syntax"
974+
# - Python >= 3.11: "arguments cannot follow var-keyword argument"
975+
error_msg = str(exc_info.value)
976+
assert any(
977+
msg in error_msg
978+
for msg in [
979+
"invalid syntax",
980+
"arguments cannot follow var-keyword argument",
981+
]
982+
)
973983

974984

975985
def test_class_definition_errors():

0 commit comments

Comments
 (0)