From 42e8a1f4a41b60c51619868f543e7b3ee82ac42f Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Wed, 15 May 2024 10:14:31 +0200 Subject: [PATCH] Fix compatibility of check_copy_ast_without_context with Py 3.13b1 Resolves: https://github.com/alexmojaki/pure_eval/issues/16 --- tests/test_utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 172f50e..3a9cc9b 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -58,7 +58,16 @@ def check_copy_ast_without_context(tree): dump1 = ast.dump(tree) dump2 = ast.dump(tree2) normalised_dump1 = re.sub( - r", ctx=(Load|Store|Del)\(\)", + # Two possible matches: + # - first one like ", ctx=…" where ", " should be removed + # - second one like "(ctx=…" where "(" should be kept + ( + r"(" + r", ctx=(Load|Store|Del)\(\)" + r"|" + r"(?<=\()ctx=(Load|Store|Del)\(\)" + r")" + ), "", dump1 )