Gentoo Archives: gentoo-commits

From: Louis Sautier <sbraz@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/testfixtures/files/, dev-python/testfixtures/
Date: Sat, 21 Aug 2021 18:42:06
Message-Id: 1629570959.9a16f9f89174086c6a8b9aae84436bb5ee31c4ea.sbraz@gentoo
1 commit: 9a16f9f89174086c6a8b9aae84436bb5ee31c4ea
2 Author: Louis Sautier <sbraz <AT> gentoo <DOT> org>
3 AuthorDate: Sat Aug 21 18:35:57 2021 +0000
4 Commit: Louis Sautier <sbraz <AT> gentoo <DOT> org>
5 CommitDate: Sat Aug 21 18:35:59 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9a16f9f8
7
8 dev-python/testfixtures: enable py3.10
9
10 Signed-off-by: Louis Sautier <sbraz <AT> gentoo.org>
11
12 .../files/testfixtures-6.18.1-py3.10.patch | 172 +++++++++++++++++++++
13 dev-python/testfixtures/testfixtures-6.18.1.ebuild | 7 +-
14 2 files changed, 178 insertions(+), 1 deletion(-)
15
16 diff --git a/dev-python/testfixtures/files/testfixtures-6.18.1-py3.10.patch b/dev-python/testfixtures/files/testfixtures-6.18.1-py3.10.patch
17 new file mode 100644
18 index 00000000000..cd1ecbd8133
19 --- /dev/null
20 +++ b/dev-python/testfixtures/files/testfixtures-6.18.1-py3.10.patch
21 @@ -0,0 +1,172 @@
22 +From 8fb2122eea0f1d0de1ccca7a3a0f5426bc6d4964 Mon Sep 17 00:00:00 2001
23 +From: Louis Sautier <sautier.louis@×××××.com>
24 +Date: Sat, 21 Aug 2021 03:00:51 +0200
25 +Subject: [PATCH] tests: fix with Python 3.10 (changed exception messages)
26 +
27 +---
28 + testfixtures/compat.py | 1 +
29 + testfixtures/tests/test_popen.py | 41 ++++++++++++++++++------------
30 + testfixtures/tests/test_replace.py | 24 ++++++++++-------
31 + 3 files changed, 41 insertions(+), 25 deletions(-)
32 +
33 +diff --git a/testfixtures/compat.py b/testfixtures/compat.py
34 +index 1042d27..ca00f32 100644
35 +--- a/testfixtures/compat.py
36 ++++ b/testfixtures/compat.py
37 +@@ -5,6 +5,7 @@
38 +
39 + PY_36_PLUS = PY_VERSION >= (3, 6)
40 + PY_37_PLUS = PY_VERSION >= (3, 7)
41 ++PY_310_PLUS = PY_VERSION >= (3, 10)
42 +
43 +
44 + if PY_VERSION > (3, 0):
45 +diff --git a/testfixtures/tests/test_popen.py b/testfixtures/tests/test_popen.py
46 +index aa211da..4ec3186 100644
47 +--- a/testfixtures/tests/test_popen.py
48 ++++ b/testfixtures/tests/test_popen.py
49 +@@ -6,7 +6,7 @@
50 + from testfixtures import ShouldRaise, compare, Replacer
51 +
52 + from testfixtures.popen import MockPopen, PopenBehaviour
53 +-from testfixtures.compat import BytesLiteral, PY2
54 ++from testfixtures.compat import BytesLiteral, PY2, PY_310_PLUS
55 +
56 + import signal
57 +
58 +@@ -471,10 +471,11 @@ def test_default_command_max_args(self):
59 + ], Popen.mock.method_calls)
60 +
61 + def test_invalid_parameters(self):
62 ++ message = "__init__() got an unexpected keyword argument 'foo'"
63 ++ if PY_310_PLUS:
64 ++ message = "MockPopenInstance." + message
65 + Popen = MockPopen()
66 +- with ShouldRaise(TypeError(
67 +- "__init__() got an unexpected keyword argument 'foo'"
68 +- )):
69 ++ with ShouldRaise(TypeError(message)):
70 + Popen(foo='bar')
71 +
72 + def test_invalid_method_or_attr(self):
73 +@@ -492,39 +493,43 @@ def test_invalid_attribute(self):
74 + process.foo
75 +
76 + def test_invalid_communicate_call(self):
77 ++ message = "communicate() got an unexpected keyword argument 'foo'"
78 ++ if PY_310_PLUS:
79 ++ message = "MockPopenInstance." + message
80 + Popen = MockPopen()
81 + Popen.set_command('bar')
82 + process = Popen('bar')
83 +- with ShouldRaise(TypeError(
84 +- "communicate() got an unexpected keyword argument 'foo'"
85 +- )):
86 ++ with ShouldRaise(TypeError(message)):
87 + process.communicate(foo='bar')
88 +
89 + def test_invalid_wait_call(self):
90 ++ message = "wait() got an unexpected keyword argument 'foo'"
91 ++ if PY_310_PLUS:
92 ++ message = "MockPopenInstance." + message
93 + Popen = MockPopen()
94 + Popen.set_command('bar')
95 + process = Popen('bar')
96 +- with ShouldRaise(TypeError(
97 +- "wait() got an unexpected keyword argument 'foo'"
98 +- )):
99 ++ with ShouldRaise(TypeError(message)):
100 + process.wait(foo='bar')
101 +
102 + def test_invalid_send_signal(self):
103 ++ message = "send_signal() got an unexpected keyword argument 'foo'"
104 ++ if PY_310_PLUS:
105 ++ message = "MockPopenInstance." + message
106 + Popen = MockPopen()
107 + Popen.set_command('bar')
108 + process = Popen('bar')
109 +- with ShouldRaise(TypeError(
110 +- "send_signal() got an unexpected keyword argument 'foo'"
111 +- )):
112 ++ with ShouldRaise(TypeError(message)):
113 + process.send_signal(foo='bar')
114 +
115 + def test_invalid_terminate(self):
116 ++ message = "terminate() got an unexpected keyword argument 'foo'"
117 ++ if PY_310_PLUS:
118 ++ message = "MockPopenInstance." + message
119 + Popen = MockPopen()
120 + Popen.set_command('bar')
121 + process = Popen('bar')
122 +- with ShouldRaise(TypeError(
123 +- "terminate() got an unexpected keyword argument 'foo'"
124 +- )):
125 ++ with ShouldRaise(TypeError(message)):
126 + process.terminate(foo='bar')
127 +
128 + def test_invalid_kill(self):
129 +@@ -535,6 +540,8 @@ def test_invalid_kill(self):
130 + text = 'kill() takes exactly 1 argument (2 given)'
131 + else:
132 + text = 'kill() takes 1 positional argument but 2 were given'
133 ++ if PY_310_PLUS:
134 ++ text = "MockPopenInstance." + text
135 + with ShouldRaise(TypeError(text)):
136 + process.kill('moo')
137 +
138 +@@ -546,6 +553,8 @@ def test_invalid_poll(self):
139 + text = 'poll() takes exactly 1 argument (2 given)'
140 + else:
141 + text = 'poll() takes 1 positional argument but 2 were given'
142 ++ if PY_310_PLUS:
143 ++ text = "MockPopenInstance." + text
144 + with ShouldRaise(TypeError(text)):
145 + process.poll('moo')
146 +
147 +diff --git a/testfixtures/tests/test_replace.py b/testfixtures/tests/test_replace.py
148 +index 5a77e23..d3544a8 100644
149 +--- a/testfixtures/tests/test_replace.py
150 ++++ b/testfixtures/tests/test_replace.py
151 +@@ -13,7 +13,7 @@
152 +
153 + from testfixtures.tests import sample1
154 + from testfixtures.tests import sample2
155 +-from ..compat import PY3
156 ++from ..compat import PY3, PY_310_PLUS
157 +
158 + from warnings import catch_warnings
159 +
160 +@@ -259,19 +259,25 @@ def test_something(obj):
161 + self.failIf(hasattr(sample1, 'foo'))
162 +
163 + def test_replace_delattr_cant_remove(self):
164 ++ if PY_310_PLUS:
165 ++ message = "cannot set 'today' attribute of " \
166 ++ "immutable type 'datetime.datetime'"
167 ++ else:
168 ++ message = "can't set attributes of " \
169 ++ "built-in/extension type 'datetime.datetime'"
170 + with Replacer() as r:
171 +- with ShouldRaise(TypeError(
172 +- "can't set attributes of "
173 +- "built-in/extension type 'datetime.datetime'"
174 +- )):
175 ++ with ShouldRaise(TypeError(message)):
176 + r.replace('datetime.datetime.today', not_there)
177 +
178 + def test_replace_delattr_cant_remove_not_strict(self):
179 ++ if PY_310_PLUS:
180 ++ message = "cannot set 'today' attribute of " \
181 ++ "immutable type 'datetime.datetime'"
182 ++ else:
183 ++ message = "can't set attributes of " \
184 ++ "built-in/extension type 'datetime.datetime'"
185 + with Replacer() as r:
186 +- with ShouldRaise(TypeError(
187 +- "can't set attributes of "
188 +- "built-in/extension type 'datetime.datetime'"
189 +- )):
190 ++ with ShouldRaise(TypeError(message)):
191 + r.replace('datetime.datetime.today', not_there, strict=False)
192 +
193 + def test_replace_dict_remove_key(self):
194
195 diff --git a/dev-python/testfixtures/testfixtures-6.18.1.ebuild b/dev-python/testfixtures/testfixtures-6.18.1.ebuild
196 index a0872c1838e..09d57b662b8 100644
197 --- a/dev-python/testfixtures/testfixtures-6.18.1.ebuild
198 +++ b/dev-python/testfixtures/testfixtures-6.18.1.ebuild
199 @@ -3,7 +3,7 @@
200
201 EAPI=8
202
203 -PYTHON_COMPAT=( python3_{8..9} )
204 +PYTHON_COMPAT=( python3_{8..10} )
205 inherit distutils-r1
206
207 DESCRIPTION="A collection of helpers and mock objects for unit tests and doc tests"
208 @@ -27,6 +27,11 @@ BDEPEND="
209 distutils_enable_sphinx docs
210 distutils_enable_tests pytest
211
212 +PATCHES=(
213 + # https://github.com/Simplistix/testfixtures/commit/8fb2122eea0f1d0de1ccca7a3a0f5426bc6d4964
214 + "${FILESDIR}/${P}-py3.10.patch"
215 +)
216 +
217 python_prepare_all() {
218 # kill weird way of declaring build deps
219 sed -e '/build=/d' -i setup.py || die