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/future/files/, dev-python/future/
Date: Fri, 15 Nov 2019 22:55:22
Message-Id: 1573858508.ed80835ba92a55f6ff0589dcc6b6da8f078a7d30.mgorny@gentoo
1 commit: ed80835ba92a55f6ff0589dcc6b6da8f078a7d30
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Fri Nov 15 22:51:39 2019 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Fri Nov 15 22:55:08 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ed80835b
7
8 dev-python/future: Enable pypy*, and fix tests on py38
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 dev-python/future/files/future-0.18.2-tests.patch | 269 ++++++++++++++++++++++
13 dev-python/future/future-0.18.2.ebuild | 6 +-
14 2 files changed, 274 insertions(+), 1 deletion(-)
15
16 diff --git a/dev-python/future/files/future-0.18.2-tests.patch b/dev-python/future/files/future-0.18.2-tests.patch
17 new file mode 100644
18 index 00000000000..3742adb7282
19 --- /dev/null
20 +++ b/dev-python/future/files/future-0.18.2-tests.patch
21 @@ -0,0 +1,269 @@
22 +diff --git a/tests/test_future/test_backports.py b/tests/test_future/test_backports.py
23 +index 9eeb741..63b1afe 100644
24 +--- a/tests/test_future/test_backports.py
25 ++++ b/tests/test_future/test_backports.py
26 +@@ -87,7 +87,8 @@ class TestChainMap(unittest.TestCase):
27 + d['b'] = 20
28 + d['c'] = 30
29 + self.assertEqual(d.maps, [{'b':20, 'c':30}, {'a':1, 'b':2}]) # check internal state
30 +- self.assertEqual(d.items(), dict(a=1, b=20, c=30).items()) # check items/iter/getitem
31 ++ self.assertEqual(sorted(d.items()),
32 ++ sorted(dict(a=1, b=20, c=30).items())) # check items/iter/getitem
33 + self.assertEqual(len(d), 3) # check len
34 + for key in 'abc': # check contains
35 + self.assertIn(key, d)
36 +@@ -96,7 +97,8 @@ class TestChainMap(unittest.TestCase):
37 +
38 + del d['b'] # unmask a value
39 + self.assertEqual(d.maps, [{'c':30}, {'a':1, 'b':2}]) # check internal state
40 +- self.assertEqual(d.items(), dict(a=1, b=2, c=30).items()) # check items/iter/getitem
41 ++ self.assertEqual(sorted(d.items()),
42 ++ sorted(dict(a=1, b=2, c=30).items())) # check items/iter/getitem
43 + self.assertEqual(len(d), 3) # check len
44 + for key in 'abc': # check contains
45 + self.assertIn(key, d)
46 +diff --git a/tests/test_future/test_builtins.py b/tests/test_future/test_builtins.py
47 +index ca07b9e..944d97b 100644
48 +--- a/tests/test_future/test_builtins.py
49 ++++ b/tests/test_future/test_builtins.py
50 +@@ -8,7 +8,7 @@ from future.builtins import (bytes, dict, int, range, round, str, super,
51 + ascii, chr, hex, input, next, oct, open, pow,
52 + filter, map, zip, min, max)
53 +
54 +-from future.utils import PY3, exec_, native_str, implements_iterator
55 ++from future.utils import PYPY, PY2, PY3, exec_, native_str, implements_iterator
56 + from future.tests.base import (unittest, skip26, expectedFailurePY2,
57 + expectedFailurePY26)
58 +
59 +@@ -699,12 +699,13 @@ class BuiltinTest(unittest.TestCase):
60 + self.assertEqual(eval('dir()', g, m), list('xyz'))
61 + self.assertEqual(eval('globals()', g, m), g)
62 + self.assertEqual(eval('locals()', g, m), m)
63 +- self.assertRaises(TypeError, eval, 'a', m)
64 ++ if not (PYPY and PY2):
65 ++ self.assertRaises(TypeError, eval, 'a', m)
66 + class A:
67 + "Non-mapping"
68 + pass
69 + m = A()
70 +- self.assertRaises(TypeError, eval, 'a', g, m)
71 ++ self.assertRaises((AttributeError, TypeError), eval, 'a', g, m)
72 +
73 + # Verify that dict subclasses work as well
74 + class D(dict):
75 +@@ -784,8 +785,9 @@ class BuiltinTest(unittest.TestCase):
76 + # self.assertRaisesRegex(NameError, "name 'print' is not defined",
77 + # exec_, code, {'__builtins__': {}})
78 + # Now:
79 +- self.assertRaises(NameError,
80 +- exec_, code, {'__builtins__': {}})
81 ++ if not PYPY:
82 ++ self.assertRaises(NameError,
83 ++ exec_, code, {'__builtins__': {}})
84 + # __builtins__ must be a mapping type
85 + # Was:
86 + # self.assertRaises(TypeError,
87 +@@ -797,8 +799,9 @@ class BuiltinTest(unittest.TestCase):
88 + # Was:
89 + # self.assertRaisesRegex(NameError, "__build_class__ not found",
90 + # exec_, code, {'__builtins__': {}})
91 +- self.assertRaises(NameError,
92 +- exec_, code, {'__builtins__': {}})
93 ++ if not PYPY:
94 ++ self.assertRaises(NameError,
95 ++ exec_, code, {'__builtins__': {}})
96 +
97 + class frozendict_error(Exception):
98 + pass
99 +@@ -1304,8 +1307,9 @@ class BuiltinTest(unittest.TestCase):
100 + self.assertAlmostEqual(pow(-1, 0.5), 1j)
101 + self.assertAlmostEqual(pow(-1, 1/3), 0.5 + 0.8660254037844386j)
102 +
103 +- # Raises TypeError in Python < v3.5, ValueError in v3.5:
104 +- self.assertRaises((TypeError, ValueError), pow, -1, -2, 3)
105 ++ if sys.hexversion < 0x03080000:
106 ++ # Raises TypeError in Python < v3.5, ValueError in v3.5:
107 ++ self.assertRaises((TypeError, ValueError), pow, -1, -2, 3)
108 + self.assertRaises(ValueError, pow, 1, 2, 0)
109 +
110 + self.assertRaises(TypeError, pow)
111 +diff --git a/tests/test_future/test_futurize.py b/tests/test_future/test_futurize.py
112 +index 0d7c42d..4590185 100644
113 +--- a/tests/test_future/test_futurize.py
114 ++++ b/tests/test_future/test_futurize.py
115 +@@ -13,7 +13,7 @@ from lib2to3.pygram import token
116 +
117 + from future.tests.base import (CodeHandler, unittest, skip26, reformat_code,
118 + order_future_lines, expectedFailurePY26)
119 +-from future.utils import PY2
120 ++from future.utils import PY2, PY3, PYPY
121 +
122 +
123 + class TestLibFuturize(unittest.TestCase):
124 +@@ -565,6 +565,7 @@ class TestFuturizeSimple(CodeHandler):
125 + # tarball.write(r2.content)
126 +
127 + @expectedFailurePY26
128 ++ @unittest.skipIf(PYPY and PY3, '')
129 + def test_raw_input(self):
130 + """
131 + Passes in a string to the waiting input() after futurize
132 +diff --git a/tests/test_future/test_int.py b/tests/test_future/test_int.py
133 +index 573a0d5..6172e48 100644
134 +--- a/tests/test_future/test_int.py
135 ++++ b/tests/test_future/test_int.py
136 +@@ -6,7 +6,7 @@ from __future__ import (absolute_import, division,
137 + print_function, unicode_literals)
138 + from future.builtins import *
139 + from future.tests.base import unittest, expectedFailurePY2
140 +-from future.utils import PY26, PY2, raise_from
141 ++from future.utils import PY26, PY2, PY3, PYPY, raise_from
142 +
143 + import sys
144 + import random
145 +@@ -357,7 +357,8 @@ class IntTestCases(unittest.TestCase):
146 + self.assertEqual(int(Foo0()), 42)
147 + self.assertEqual(int(Foo1()), 42)
148 + self.assertEqual(int(Foo2()), 42)
149 +- self.assertEqual(int(Foo3()), 0)
150 ++ if not (PYPY and PY3):
151 ++ self.assertEqual(int(Foo3()), 0)
152 + self.assertEqual(int(Foo4()), 42)
153 + self.assertRaises(TypeError, int, Foo5())
154 +
155 +diff --git a/tests/test_future/test_isinstance.py b/tests/test_future/test_isinstance.py
156 +index 33c0a58..ccda709 100644
157 +--- a/tests/test_future/test_isinstance.py
158 ++++ b/tests/test_future/test_isinstance.py
159 +@@ -4,6 +4,7 @@ From the Python 3.3 test suite
160 +
161 + from __future__ import (absolute_import, division, unicode_literals)
162 + from future.builtins import *
163 ++from future.utils import PYPY
164 +
165 + # Tests some corner cases with isinstance() and issubclass(). While these
166 + # tests use new style classes and properties, they actually do whitebox
167 +@@ -264,11 +265,13 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
168 + self.assertEqual(True, issubclass(int, (int, (float, int))))
169 + self.assertEqual(True, issubclass(str, (str, (Child, NewChild, str))))
170 +
171 ++ @unittest.skipIf(PYPY, '')
172 + def test_subclass_recursion_limit(self):
173 + # make sure that issubclass raises RuntimeError before the C stack is
174 + # blown
175 + self.assertRaises(RuntimeError, blowstack, issubclass, str, str)
176 +
177 ++ @unittest.skipIf(PYPY, '')
178 + def test_isinstance_recursion_limit(self):
179 + # make sure that issubclass raises RuntimeError before the C stack is
180 + # blown
181 +diff --git a/tests/test_future/test_str.py b/tests/test_future/test_str.py
182 +index 5108548..eac602f 100644
183 +--- a/tests/test_future/test_str.py
184 ++++ b/tests/test_future/test_str.py
185 +@@ -201,6 +201,7 @@ class TestStr(unittest.TestCase):
186 + with self.assertRaises(TypeError):
187 + s.join(byte_strings2)
188 +
189 ++ @unittest.skipIf(utils.PYPY and utils.PY2, '')
190 + def test_str_join_staticmethod(self):
191 + """
192 + Issue #33
193 +@@ -430,10 +431,11 @@ class TestStr(unittest.TestCase):
194 + e = s * long(4)
195 + self.assertTrue(isinstance(e, str))
196 + self.assertEqual(e, u'ABCABCABCABC')
197 +- with self.assertRaises(TypeError):
198 +- s * 3.3
199 +- with self.assertRaises(TypeError):
200 +- s * (3.3 + 3j)
201 ++ if not (utils.PYPY and utils.PY2):
202 ++ with self.assertRaises(TypeError):
203 ++ s * 3.3
204 ++ with self.assertRaises(TypeError):
205 ++ s * (3.3 + 3j)
206 +
207 + def test_rmul(self):
208 + s = str(u'XYZ')
209 +@@ -447,10 +449,11 @@ class TestStr(unittest.TestCase):
210 + e = long(3) * s
211 + self.assertTrue(isinstance(e, str))
212 + self.assertEqual(e, u'XYZXYZXYZ')
213 +- with self.assertRaises(TypeError):
214 +- 3.3 * s
215 +- with self.assertRaises(TypeError):
216 +- (3.3 + 3j) * s
217 ++ if not (utils.PYPY and utils.PY2):
218 ++ with self.assertRaises(TypeError):
219 ++ 3.3 * s
220 ++ with self.assertRaises(TypeError):
221 ++ (3.3 + 3j) * s
222 +
223 + @unittest.skip('Fails on Python <= 2.7.6 due to string subclass slicing bug')
224 + def test_slice(self):
225 +diff --git a/tests/test_future/test_urllib2.py b/tests/test_future/test_urllib2.py
226 +index 2d69dad..3750737 100644
227 +--- a/tests/test_future/test_urllib2.py
228 ++++ b/tests/test_future/test_urllib2.py
229 +@@ -691,10 +691,7 @@ class HandlerTests(unittest.TestCase):
230 + h = NullFTPHandler(data)
231 + h.parent = MockOpener()
232 +
233 +- # MIME guessing works in Python 3.8!
234 + guessed_mime = None
235 +- if sys.hexversion >= 0x03080000:
236 +- guessed_mime = "image/gif"
237 + for url, host, port, user, passwd, type_, dirs, filename, mimetype in [
238 + ("ftp://localhost/foo/bar/baz.html",
239 + "localhost", ftplib.FTP_PORT, "", "", "I",
240 +diff --git a/tests/test_past/test_builtins.py b/tests/test_past/test_builtins.py
241 +index d16978e..f37b26c 100644
242 +--- a/tests/test_past/test_builtins.py
243 ++++ b/tests/test_past/test_builtins.py
244 +@@ -21,6 +21,7 @@ import random
245 + from os import unlink
246 + from operator import neg
247 + from future.tests.base import unittest, expectedFailurePY3, skip26
248 ++from future.utils import PYPY, PY2
249 +
250 + # count the number of test runs.
251 + # used to skip running test_execfile() multiple times
252 +@@ -423,6 +424,7 @@ class BuiltinTest(unittest.TestCase):
253 + self.assertRaises(TypeError, eval, ())
254 +
255 + @expectedFailurePY3
256 ++ @unittest.skipIf(PYPY and PY2, '')
257 + def test_general_eval(self):
258 + # Tests that general mappings can be used for the locals argument
259 +
260 +@@ -1174,7 +1176,8 @@ class BuiltinTest(unittest.TestCase):
261 + def __cmp__(self, other):
262 + raise RuntimeError
263 + __hash__ = None # Invalid cmp makes this unhashable
264 +- self.assertRaises(RuntimeError, range, a, a + 1, badzero(1))
265 ++ if not (PYPY and PY2):
266 ++ self.assertRaises(RuntimeError, range, a, a + 1, badzero(1))
267 +
268 + # Reject floats.
269 + self.assertRaises(TypeError, range, 1., 1., 1.)
270 +diff --git a/tests/test_past/test_olddict.py b/tests/test_past/test_olddict.py
271 +index 9f21060..539c277 100644
272 +--- a/tests/test_past/test_olddict.py
273 ++++ b/tests/test_past/test_olddict.py
274 +@@ -7,7 +7,7 @@ from __future__ import absolute_import, unicode_literals, print_function
275 + import os
276 + import sys
277 +
278 +-from future.utils import implements_iterator, PY3
279 ++from future.utils import implements_iterator, PYPY, PY2, PY3
280 + from future.tests.base import unittest, skip26
281 + from past.builtins import dict
282 +
283 +@@ -415,6 +415,7 @@ class Py2DictTest(unittest.TestCase):
284 + self.assertRaises(Exc, d.setdefault, x, [])
285 +
286 + @skip26
287 ++ @unittest.skipIf(PYPY, '')
288 + def test_setdefault_atomic(self):
289 + # Issue #13521: setdefault() calls __hash__ and __eq__ only once.
290 + class Hashed(object):
291
292 diff --git a/dev-python/future/future-0.18.2.ebuild b/dev-python/future/future-0.18.2.ebuild
293 index 0aee1d1a931..8b471a58cec 100644
294 --- a/dev-python/future/future-0.18.2.ebuild
295 +++ b/dev-python/future/future-0.18.2.ebuild
296 @@ -3,7 +3,7 @@
297
298 EAPI=7
299
300 -PYTHON_COMPAT=( python{2_7,3_{5,6,7}} )
301 +PYTHON_COMPAT=( python{2_7,3_{5,6,7}} pypy{,3} )
302
303 inherit distutils-r1
304
305 @@ -33,6 +33,10 @@ BDEPEND="
306 )
307 "
308
309 +PATCHES=(
310 + "${FILESDIR}"/${P}-tests.patch
311 +)
312 +
313 python_check_deps() {
314 use doc || return 0
315 has_version "dev-python/sphinx[${PYTHON_USEDEP}]" &&