Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/testtools/, dev-python/testtools/files/
Date: Sat, 21 May 2022 11:22:29
Message-Id: 1653132142.75bb6d5fca7fecaa87e51590e0503ee6dd949eea.mgorny@gentoo
1 commit: 75bb6d5fca7fecaa87e51590e0503ee6dd949eea
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 21 10:47:07 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sat May 21 11:22:22 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=75bb6d5f
7
8 dev-python/testtools: Enable py3.11
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 .../testtools/files/testtools-2.5.0-py311.patch | 116 +++++++++++++++++++++
13 dev-python/testtools/testtools-2.5.0-r1.ebuild | 9 +-
14 2 files changed, 123 insertions(+), 2 deletions(-)
15
16 diff --git a/dev-python/testtools/files/testtools-2.5.0-py311.patch b/dev-python/testtools/files/testtools-2.5.0-py311.patch
17 new file mode 100644
18 index 000000000000..ee457f6119c3
19 --- /dev/null
20 +++ b/dev-python/testtools/files/testtools-2.5.0-py311.patch
21 @@ -0,0 +1,116 @@
22 +From 77953cf633ecd149b2c29e616f8d9d4e0cf8e5fa Mon Sep 17 00:00:00 2001
23 +From: Colin Watson <cjwatson@×××××××××.com>
24 +Date: Sat, 23 Apr 2022 22:53:48 +0100
25 +Subject: [PATCH] Fix various test failures with Python 3.11
26 +
27 +The changes for https://peps.python.org/pep-0657/ require a number of
28 +changes in our tests.
29 +
30 +Some tests still fail due to
31 +https://twistedmatrix.com/trac/ticket/10336, so I'm not adding
32 +3.11 to the test matrix yet.
33 +
34 +Fixes #325.
35 +---
36 + testtools/tests/test_run.py | 4 ++--
37 + testtools/tests/test_testresult.py | 23 +++++++++++++----------
38 + testtools/tests/test_testsuite.py | 2 +-
39 + 3 files changed, 16 insertions(+), 13 deletions(-)
40 +
41 +diff --git a/testtools/tests/test_run.py b/testtools/tests/test_run.py
42 +index ee96eec9..9808421b 100644
43 +--- a/testtools/tests/test_run.py
44 ++++ b/testtools/tests/test_run.py
45 +@@ -202,9 +202,9 @@ def test_run_list_failed_import(self):
46 + Failed to import test module: runexample
47 + Traceback (most recent call last):
48 + File ".../loader.py", line ..., in _find_test_path
49 +- package = self._get_module_from_name(name)
50 ++ package = self._get_module_from_name(name)...
51 + File ".../loader.py", line ..., in _get_module_from_name
52 +- __import__(name)
53 ++ __import__(name)...
54 + File ".../runexample/__init__.py", line 1
55 + class not in
56 + ...^...
57 +diff --git a/testtools/tests/test_testresult.py b/testtools/tests/test_testresult.py
58 +index 4fbf15d1..7824ff46 100644
59 +--- a/testtools/tests/test_testresult.py
60 ++++ b/testtools/tests/test_testresult.py
61 +@@ -1266,11 +1266,11 @@ def test_traceback_formatting_without_stack_hidden(self):
62 + DocTestMatches(
63 + 'Traceback (most recent call last):\n'
64 + ' File "...testtools...runtest.py", line ..., in _run_user\n'
65 +- ' return fn(*args, **kwargs)\n'
66 ++ ' return fn(*args, **kwargs)\n...'
67 + ' File "...testtools...testcase.py", line ..., in _run_test_method\n'
68 +- ' return self._get_test_method()()\n'
69 ++ ' return self._get_test_method()()\n...'
70 + ' File "...testtools...tests...test_testresult.py", line ..., in error\n'
71 +- ' 1/0\n'
72 ++ ' 1/0\n...'
73 + 'ZeroDivisionError: ...\n',
74 + doctest.ELLIPSIS | doctest.REPORT_UDIFF))
75 +
76 +@@ -1283,7 +1283,7 @@ def test_traceback_formatting_with_stack_hidden(self):
77 + DocTestMatches(
78 + 'Traceback (most recent call last):\n'
79 + ' File "...testtools...tests...test_testresult.py", line ..., in error\n'
80 +- ' 1/0\n'
81 ++ ' 1/0\n...'
82 + 'ZeroDivisionError: ...\n',
83 + doctest.ELLIPSIS))
84 +
85 +@@ -1322,17 +1322,17 @@ def test_traceback_with_locals(self):
86 + DocTestMatches(
87 + 'Traceback (most recent call last):\n'
88 + ' File "...testtools...runtest.py", line ..., in _run_user\n'
89 +- ' return fn(*args, **kwargs)\n'
90 ++ ' return fn(*args, **kwargs)\n...'
91 + ' args = ...\n'
92 + ' fn = ...\n'
93 + ' kwargs = ...\n'
94 + ' self = ...\n'
95 + ' File "...testtools...testcase.py", line ..., in _run_test_method\n'
96 +- ' return self._get_test_method()()\n'
97 ++ ' return self._get_test_method()()\n...'
98 + ' result = ...\n'
99 + ' self = ...\n'
100 + ' File "...testtools...tests...test_testresult.py", line ..., in error\n'
101 +- ' 1/0\n'
102 ++ ' 1/0\n...'
103 + ' a = 1\n'
104 + ' self = ...\n'
105 + 'ZeroDivisionError: ...\n',
106 +@@ -2645,12 +2645,15 @@ def test_unprintable_exception(self):
107 + " raise RuntimeError\n"
108 + " def __repr__(self):\n"
109 + " raise RuntimeError\n")
110 ++ if sys.version_info >= (3, 11):
111 ++ expected = "UnprintableError: <exception str() failed>\n"
112 ++ else:
113 ++ expected = (
114 ++ "UnprintableError: <unprintable UnprintableError object>\n")
115 + textoutput = self._test_external_case(
116 + modulelevel=exception_class,
117 + testline="raise UnprintableError")
118 +- self.assertIn(self._as_output(
119 +- "UnprintableError: <unprintable UnprintableError object>\n"),
120 +- textoutput)
121 ++ self.assertIn(self._as_output(expected), textoutput)
122 +
123 + def test_non_ascii_dirname(self):
124 + """Script paths in the traceback can be non-ascii"""
125 +diff --git a/testtools/tests/test_testsuite.py b/testtools/tests/test_testsuite.py
126 +index 65cb88d7..01abb23c 100644
127 +--- a/testtools/tests/test_testsuite.py
128 ++++ b/testtools/tests/test_testsuite.py
129 +@@ -178,7 +178,7 @@ def run(self):
130 + "Traceback (most recent call last):\n")
131 + self.assertThat(events[2][6].decode('utf8'), DocTestMatches("""\
132 + File "...testtools/testsuite.py", line ..., in _run_test
133 +- test.run(process_result)
134 ++ test.run(process_result)...
135 + """, doctest.ELLIPSIS))
136 + self.assertThat(events[3][6].decode('utf8'), DocTestMatches("""\
137 + TypeError: ...run() takes ...1 ...argument...2...given...
138
139 diff --git a/dev-python/testtools/testtools-2.5.0-r1.ebuild b/dev-python/testtools/testtools-2.5.0-r1.ebuild
140 index 5b4ff96df657..a6fe6fe82954 100644
141 --- a/dev-python/testtools/testtools-2.5.0-r1.ebuild
142 +++ b/dev-python/testtools/testtools-2.5.0-r1.ebuild
143 @@ -4,7 +4,7 @@
144 EAPI=8
145
146 DISTUTILS_USE_PEP517=setuptools
147 -PYTHON_COMPAT=( python3_{8..10} pypy3 )
148 +PYTHON_COMPAT=( python3_{8..11} pypy3 )
149 PYTHON_REQ_USE="threads(+)"
150
151 inherit distutils-r1
152 @@ -41,8 +41,13 @@ PDEPEND="
153
154 distutils_enable_sphinx doc
155
156 +PATCHES=(
157 + # https://github.com/testing-cabal/testtools/pull/328
158 + "${FILESDIR}"/${P}-py311.patch
159 +)
160 +
161 src_prepare() {
162 - # very fragile to formatting changes
163 + # very fragile to formatting changes (broken on py3.10 & pypy3)
164 sed -i -e 's:test_syntax_error(:_&:' \
165 testtools/tests/test_testresult.py || die