summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-08-05 09:13:58 +0200
committerMichał Górny <mgorny@gentoo.org>2021-08-05 09:29:07 +0200
commitbb5e0c79326b1e75f68e2fd75639c0f1cfae6bd5 (patch)
tree56f616e04a1d507c62fb6ce91207da9ef31d0063 /dev-python/parso
parentdev-python/parso: Backport flaky test fix (diff)
downloadgentoo-bb5e0c79326b1e75f68e2fd75639c0f1cfae6bd5.tar.gz
gentoo-bb5e0c79326b1e75f68e2fd75639c0f1cfae6bd5.tar.bz2
gentoo-bb5e0c79326b1e75f68e2fd75639c0f1cfae6bd5.zip
dev-python/parso: Fix py3.10.0rc1 test failures
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/parso')
-rw-r--r--dev-python/parso/files/parso-0.8.2-py310-2.patch57
-rw-r--r--dev-python/parso/parso-0.8.2.ebuild2
2 files changed, 58 insertions, 1 deletions
diff --git a/dev-python/parso/files/parso-0.8.2-py310-2.patch b/dev-python/parso/files/parso-0.8.2-py310-2.patch
new file mode 100644
index 000000000000..7c6b1ad78286
--- /dev/null
+++ b/dev-python/parso/files/parso-0.8.2-py310-2.patch
@@ -0,0 +1,57 @@
+From dc41958947770849c8b3b4d344db434e2c8548cc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Thu, 5 Aug 2021 09:09:28 +0200
+Subject: [PATCH] Update expected exception line numbers for Python 3.10.0rc1
+
+It seems that upstream has fixed line numbers in some of the expections
+in Python 3.10.0rc1, so update the tests accordingly. This means that
+test_non_async_in_async() gets the correct line again,
+and test_default_except_error_postition() no longer suffers from
+the apparent off-by-one problem.
+
+This doesn't fix tests entirely with Python 3.10 but it's a step
+forward.
+---
+ test/test_python_errors.py | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/test/test_python_errors.py b/test/test_python_errors.py
+index cda9bd2..e847ebb 100644
+--- a/test/test_python_errors.py
++++ b/test/test_python_errors.py
+@@ -57,10 +57,10 @@ def test_non_async_in_async():
+ error, = errors
+ actual = error.message
+ assert actual in wanted
+- if sys.version_info[:2] < (3, 8):
++ if sys.version_info[:2] not in ((3, 8), (3,9)):
+ assert line_nr == error.start_pos[0]
+ else:
+- assert line_nr == 0 # For whatever reason this is zero in Python 3.8+
++ assert line_nr == 0 # For whatever reason this is zero in Python 3.8/3.9
+
+
+ @pytest.mark.parametrize(
+@@ -140,13 +140,16 @@ def _get_actual_exception(code):
+
+
+ def test_default_except_error_postition():
+- # For this error the position seemed to be one line off, but that doesn't
+- # really matter.
++ # For this error the position seemed to be one line off in Python < 3.10,
++ # but that doesn't really matter.
+ code = 'try: pass\nexcept: pass\nexcept X: pass'
+ wanted, line_nr = _get_actual_exception(code)
+ error, = _get_error_list(code)
+ assert error.message in wanted
+- assert line_nr != error.start_pos[0]
++ if sys.version_info[:2] >= (3, 10):
++ assert line_nr == error.start_pos[0]
++ else:
++ assert line_nr != error.start_pos[0]
+ # I think this is the better position.
+ assert error.start_pos[0] == 2
+
+--
+2.32.0
+
diff --git a/dev-python/parso/parso-0.8.2.ebuild b/dev-python/parso/parso-0.8.2.ebuild
index 2637f5cf5c31..42be4262b424 100644
--- a/dev-python/parso/parso-0.8.2.ebuild
+++ b/dev-python/parso/parso-0.8.2.ebuild
@@ -20,6 +20,7 @@ distutils_enable_tests pytest
PATCHES=(
"${FILESDIR}"/${P}-py310.patch
+ "${FILESDIR}"/${P}-py310-2.patch
"${FILESDIR}"/${P}-flaky-test.patch
)
@@ -28,7 +29,6 @@ python_test() {
[[ ${EPYTHON} == python3.10 ]] && deselect+=(
# py3.10 changed exception messages
test/test_python_errors.py::test_python_exception_matches
- test/test_python_errors.py::test_default_except_error_postition
)
epytest ${deselect[@]/#/--deselect }
}