1 |
commit: 1e585f9441fc78d1aca5fabc45836f0c8da48f73 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jul 5 10:27:38 2021 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jul 5 10:56:20 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1e585f94 |
7 |
|
8 |
dev-python/testtools: Port to py3.10 |
9 |
|
10 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
11 |
|
12 |
.../testtools/files/testtools-2.4.0-py310.patch | 43 ++++++++++++++++++++++ |
13 |
dev-python/testtools/testtools-2.4.0-r2.ebuild | 6 ++- |
14 |
2 files changed, 48 insertions(+), 1 deletion(-) |
15 |
|
16 |
diff --git a/dev-python/testtools/files/testtools-2.4.0-py310.patch b/dev-python/testtools/files/testtools-2.4.0-py310.patch |
17 |
new file mode 100644 |
18 |
index 00000000000..d2d0c092d14 |
19 |
--- /dev/null |
20 |
+++ b/dev-python/testtools/files/testtools-2.4.0-py310.patch |
21 |
@@ -0,0 +1,43 @@ |
22 |
+From d528842b99b16efce212e15dae3f0a54927d06d8 Mon Sep 17 00:00:00 2001 |
23 |
+From: Cyril Roelandt <cyril@××××××.com> |
24 |
+Date: Fri, 19 Mar 2021 02:50:13 +0000 |
25 |
+Subject: [PATCH] Fix tests with Python 3.10 |
26 |
+ |
27 |
+In Python 3, error messages have become a bit more precise. For |
28 |
+instance, the following code snippet: |
29 |
+ |
30 |
+---- |
31 |
+class Foo(): |
32 |
+ def bar(self, a): |
33 |
+ pass |
34 |
+ |
35 |
+try: |
36 |
+ Foo().bar(1, 2) |
37 |
+except TypeError as e: |
38 |
+ print(e) |
39 |
+---- |
40 |
+ |
41 |
+will return: |
42 |
+ |
43 |
+- in Python 3.9: "bar() takes 2 positional arguments but 3 were given" |
44 |
+- in Python 3.10: "Foo.bar() takes 2 positional arguments but 3 were |
45 |
+ given" |
46 |
+ |
47 |
+Fix our tests accordingly. |
48 |
+--- |
49 |
+ testtools/tests/test_testsuite.py | 2 +- |
50 |
+ 1 file changed, 1 insertion(+), 1 deletion(-) |
51 |
+ |
52 |
+diff --git a/testtools/tests/test_testsuite.py b/testtools/tests/test_testsuite.py |
53 |
+index 7ad5b74d..65cb88d7 100644 |
54 |
+--- a/testtools/tests/test_testsuite.py |
55 |
++++ b/testtools/tests/test_testsuite.py |
56 |
+@@ -181,7 +181,7 @@ def run(self): |
57 |
+ test.run(process_result) |
58 |
+ """, doctest.ELLIPSIS)) |
59 |
+ self.assertThat(events[3][6].decode('utf8'), DocTestMatches("""\ |
60 |
+-TypeError: run() takes ...1 ...argument...2...given... |
61 |
++TypeError: ...run() takes ...1 ...argument...2...given... |
62 |
+ """, doctest.ELLIPSIS)) |
63 |
+ events = [event[0:10] + (None,) for event in events] |
64 |
+ events[1] = events[1][:6] + (None,) + events[1][7:] |
65 |
|
66 |
diff --git a/dev-python/testtools/testtools-2.4.0-r2.ebuild b/dev-python/testtools/testtools-2.4.0-r2.ebuild |
67 |
index 2e853225cf7..7f1282058fc 100644 |
68 |
--- a/dev-python/testtools/testtools-2.4.0-r2.ebuild |
69 |
+++ b/dev-python/testtools/testtools-2.4.0-r2.ebuild |
70 |
@@ -3,7 +3,7 @@ |
71 |
|
72 |
EAPI=8 |
73 |
|
74 |
-PYTHON_COMPAT=( python3_{8..9} pypy3 ) |
75 |
+PYTHON_COMPAT=( python3_{8..10} pypy3 ) |
76 |
PYTHON_REQ_USE="threads(+)" |
77 |
|
78 |
inherit distutils-r1 |
79 |
@@ -33,6 +33,7 @@ PDEPEND=">=dev-python/fixtures-1.3.0[${PYTHON_USEDEP}]" |
80 |
|
81 |
PATCHES=( |
82 |
"${FILESDIR}"/testtools-2.4.0-py39.patch |
83 |
+ "${FILESDIR}"/testtools-2.4.0-py310.patch |
84 |
"${FILESDIR}"/testtools-2.4.0-assertitemsequal.patch |
85 |
) |
86 |
|
87 |
@@ -47,6 +48,9 @@ src_prepare() { |
88 |
sed -i -e 's:unittest2:unittest:' {} + || die |
89 |
sed -i -e 's/^traceback =.*/import traceback/' \ |
90 |
testtools/content.py || die |
91 |
+ # py3.10 changed the output |
92 |
+ sed -i -e 's:test_syntax_error:_&:' \ |
93 |
+ testtools/tests/test_testresult.py || die |
94 |
distutils-r1_src_prepare |
95 |
} |