diff --git a/1525.patch b/1525.patch new file mode 100644 index 0000000..1528f23 --- /dev/null +++ b/1525.patch @@ -0,0 +1,33 @@ +From e32c985af3a419ae2ea0853ad8084a12ab62745b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Tue, 2 Nov 2021 16:47:28 +0100 +Subject: [PATCH] Tests: Make "Traceback did not match" an actual f-string + +Otherwise the failure looks like this: + + > assert ( + m is not None + ), "Traceback did not match:\n\n{''.join(tb)}\nexpected:\n{expected_tb}" + E AssertionError: Traceback did not match: + E + E {''.join(tb)} + E expected: + E {expected_tb} + E assert None is not None +--- + tests/test_debug.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/test_debug.py b/tests/test_debug.py +index 0aec78ae4..c639bbc29 100644 +--- a/tests/test_debug.py ++++ b/tests/test_debug.py +@@ -25,7 +25,7 @@ def assert_traceback_matches(self, callback, expected_tb): + m = re.search(expected_tb.strip(), "".join(tb)) + assert ( + m is not None +- ), "Traceback did not match:\n\n{''.join(tb)}\nexpected:\n{expected_tb}" ++ ), f"Traceback did not match:\n\n{''.join(tb)}\nexpected:\n{expected_tb}" + + def test_runtime_error(self, fs_env): + def test(): diff --git a/1527.patch b/1527.patch new file mode 100644 index 0000000..e5b0b2b --- /dev/null +++ b/1527.patch @@ -0,0 +1,56 @@ +From 757756696ceebf9967ad8b8c6df60a2be7f23c51 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Thu, 4 Nov 2021 18:03:06 +0100 +Subject: [PATCH] Tests: Adapt expected traceback regexes for Python 3.11.0a1 + +Fixes https://github.com/pallets/jinja/issues/1526 + +Before: + + File ".../broken.html", line 2, in + {{ fail() }} + File ".../test_debug.py", line 32, in + tmpl.render(fail=lambda: 1 / 0) + ZeroDivisionError: division by zero + +After: + + File ".../broken.html", line 2, in + {{ fail() }} + ^^^^^^^^^^^^ + File ".../test_debug.py", line 32, in + tmpl.render(fail=lambda: 1 / 0) + ~~^~~ + ZeroDivisionError: division by zero +--- + tests/test_debug.py | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/tests/test_debug.py b/tests/test_debug.py +index 0aec78ae4..1cb931cfc 100644 +--- a/tests/test_debug.py ++++ b/tests/test_debug.py +@@ -36,9 +36,11 @@ def test(): + test, + r""" + File ".*?broken.html", line 2, in (top-level template code|) +- \{\{ fail\(\) \}\} ++ \{\{ fail\(\) \}\}( ++ \^{12})? + File ".*debug?.pyc?", line \d+, in +- tmpl\.render\(fail=lambda: 1 / 0\) ++ tmpl\.render\(fail=lambda: 1 / 0\)( ++ ~~\^~~)? + ZeroDivisionError: (int(eger)? )?division (or modulo )?by zero + """, + ) +@@ -66,7 +68,8 @@ def test(): + test, + r""" + File ".*debug.pyc?", line \d+, in test +- raise TemplateSyntaxError\("wtf", 42\) ++ raise TemplateSyntaxError\("wtf", 42\)( ++ \^{36})? + (jinja2\.exceptions\.)?TemplateSyntaxError: wtf + line 42""", + ) diff --git a/python-jinja2.spec b/python-jinja2.spec index 4b68047..01afdbf 100644 --- a/python-jinja2.spec +++ b/python-jinja2.spec @@ -8,6 +8,11 @@ License: BSD URL: https://palletsprojects.com/p/jinja/ Source0: %{pypi_source} +# Tests: Make "Traceback did not match" an actual f-string +Patch1: https://github.com/pallets/jinja/pull/1525.patch +# Tests: Adapt expected traceback regexes for Python 3.11.0a1 +Patch2: https://github.com/pallets/jinja/pull/1527.patch + %if 0%{?fedora} || 0%{?rhel} > 7 # Enable python3 build by default %bcond_without python3