Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/twisted/files/, dev-python/twisted/
Date: Fri, 31 Mar 2017 21:11:31
Message-Id: 1490994531.60c130fb3c577d11be4f0cb4fe15696f8e2e9a2d.dolsen@gentoo
1 commit: 60c130fb3c577d11be4f0cb4fe15696f8e2e9a2d
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Fri Mar 31 20:18:47 2017 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Fri Mar 31 21:08:51 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=60c130fb
7
8 dev-python/twisted: Work on the test patches, separate some for upstream submission
9
10 Separate several test fixes and improve them for possible inclusion upstream.
11 Determined that there were some python anomlies occuring causing some utf8 test failures.
12 Isolate those with an UTF8_OVERRIDES environment variable. Then run them separately
13 after the main twisted test run.
14 Adjust the ebuild to suit the patch and test changes.
15
16 Package-Manager: Portage-2.3.5, Repoman-2.3.2_p30
17
18 dev-python/twisted/files/test_main.patch | 73 +++++++++++++
19 .../twisted/files/twisted-16.6.0-test-fixes.patch | 114 ++-------------------
20 dev-python/twisted/files/utf8_overrides.patch | 64 ++++++++++++
21 ...sted-16.6.0.ebuild => twisted-16.6.0-r1.ebuild} | 12 +++
22 4 files changed, 157 insertions(+), 106 deletions(-)
23
24 diff --git a/dev-python/twisted/files/test_main.patch b/dev-python/twisted/files/test_main.patch
25 new file mode 100644
26 index 00000000000..bfef40450d5
27 --- /dev/null
28 +++ b/dev-python/twisted/files/test_main.patch
29 @@ -0,0 +1,73 @@
30 +From 2c3c28f5dbbd61bcfa5c548d1d423fffbaf2132d Mon Sep 17 00:00:00 2001
31 +From: Brian Dolbec <dolsen@g.o>
32 +Date: Fri, 31 Mar 2017 09:32:18 -0700
33 +Subject: [PATCH] tests/test_main.py: Fix test_twisted to handle differntly
34 + sorted options
35 +
36 +Some systems retuned the usage with '__main__.py' instead of the command 'trial'
37 +So, substitute that out if it exists.
38 +The options returned via python can be a different sort order than is output via the
39 +command --help. So break up the lines into a list and check equality, lines are neither
40 +missing or extra.
41 +---
42 + src/twisted/test/test_main.py | 34 ++++++++++++++++++++++++++++++++--
43 + 1 file changed, 32 insertions(+), 2 deletions(-)
44 +
45 +diff --git a/src/twisted/test/test_main.py b/src/twisted/test/test_main.py
46 +index 572769018..b010a389e 100644
47 +--- a/src/twisted/test/test_main.py
48 ++++ b/src/twisted/test/test_main.py
49 +@@ -18,6 +18,10 @@ from twisted.trial.unittest import TestCase
50 +
51 + class MainTests(TestCase):
52 + """Test that twisted scripts can be invoked as modules."""
53 ++ # this test just does not work correctly on Gentoo
54 ++ # the output has '__main__.py' instead of 'trial'
55 ++ # I have only been able to get 2.7 working correctly
56 ++ # with replacing the value with what is expected.
57 + def test_twisted(self):
58 + """Invoking python -m twisted should execute twist."""
59 + cmd = sys.executable
60 +@@ -28,11 +32,37 @@ class MainTests(TestCase):
61 +
62 + def processEnded(ign):
63 + f = p.outF
64 +- output = f.getvalue().replace(b'\r\n', b'\n')
65 ++ # Some systems may return __main__.py instead of the command name expected
66 ++ output = f.getvalue().replace(b'\r\n', b'\n').replace(b"__main__.py", b"trial")
67 +
68 + options = TwistOptions()
69 + message = '{}\n'.format(options).encode('utf-8')
70 +- self.assertEqual(output, message)
71 ++ # NOTE: python may return the options in a different order
72 ++ # than is output via the command --help option
73 ++ # so we must break up the text and compare that lines
74 ++ # are not missing or extra from what is expected
75 ++ a = output.split(b'\n')
76 ++ b = message.split(b'\n')
77 ++ extras = []
78 ++ missing = []
79 ++ equal_len = (len(a) == len(b))
80 ++ for i in a:
81 ++ if i not in b:
82 ++ extras.append(i)
83 ++ for i in b:
84 ++ if i not in a:
85 ++ missing.append(i)
86 ++
87 ++ self.assertTrue(equal_len,
88 ++ msg="Usage reported a different number of lines than expected")
89 ++ self.assertTrue(extras == [],
90 ++ msg="Usage returned these extra lines not expected: %s"
91 ++ % '\n'.join(extras)
92 ++ )
93 ++ self.assertTrue(missing == [],
94 ++ msg="Usage was missing these expected lines: %s"
95 ++ % '\n'.join(missing)
96 ++ )
97 + return d.addCallback(processEnded)
98 +
99 + def test_twisted_import(self):
100 +--
101 +2.12.1
102 +
103
104 diff --git a/dev-python/twisted/files/twisted-16.6.0-test-fixes.patch b/dev-python/twisted/files/twisted-16.6.0-test-fixes.patch
105 index a04cafd1ccb..3ce04aa3f68 100644
106 --- a/dev-python/twisted/files/twisted-16.6.0-test-fixes.patch
107 +++ b/dev-python/twisted/files/twisted-16.6.0-test-fixes.patch
108 @@ -1,7 +1,7 @@
109 -From 7fddbadde3f1f65c1ef78223e6af98a066a2315b Mon Sep 17 00:00:00 2001
110 +From 91b6d8b5b9d602152fb7148c6e2921463b93a8a5 Mon Sep 17 00:00:00 2001
111 From: Brian Dolbec <dolsen@g.o>
112 -Date: Wed, 29 Mar 2017 18:28:45 -0700
113 -Subject: [PATCH] Twisted-16.6.0 test fixes
114 +Date: Fri, 31 Mar 2017 10:55:32 -0700
115 +Subject: [PATCH] twisted test overrides
116
117 ---
118 src/twisted/internet/test/test_gireactor.py | 3 ++-
119 @@ -10,14 +10,11 @@ Subject: [PATCH] Twisted-16.6.0 test fixes
120 src/twisted/pair/test/test_rawudp.py | 10 +++++++++-
121 src/twisted/pair/test/test_tuntap.py | 16 ++++++++++++++++
122 src/twisted/python/test/test_dist3.py | 2 ++
123 - src/twisted/test/test_ident.py | 7 ++++++-
124 - src/twisted/test/test_main.py | 8 +++++++-
125 + src/twisted/test/test_ident.py | 5 ++++-
126 src/twisted/test/test_plugin.py | 6 ++++++
127 src/twisted/test/test_policies.py | 5 +++++
128 - src/twisted/test/test_reflect.py | 3 ++-
129 - src/twisted/test/test_twistd.py | 21 ++++++++++++++-------
130 src/twisted/test/test_udp.py | 6 ++++++
131 - 13 files changed, 92 insertions(+), 12 deletions(-)
132 + 10 files changed, 67 insertions(+), 3 deletions(-)
133
134 diff --git a/src/twisted/internet/test/test_gireactor.py b/src/twisted/internet/test/test_gireactor.py
135 index 43147fdce..6333218e7 100644
136 @@ -169,17 +166,10 @@ index 3ce2bdd60..494674bc7 100644
137 +
138 +ModulesToInstallTests.skip = "This is an upstream distribution test only"
139 diff --git a/src/twisted/test/test_ident.py b/src/twisted/test/test_ident.py
140 -index d86b840e5..028778a2d 100644
141 +index d86b840e5..3cc40261f 100644
142 --- a/src/twisted/test/test_ident.py
143 +++ b/src/twisted/test/test_ident.py
144 -@@ -6,13 +6,14 @@
145 - Test cases for twisted.protocols.ident module.
146 - """
147 -
148 -+import os
149 - import struct
150 -
151 - from twisted.protocols import ident
152 +@@ -12,7 +12,7 @@ from twisted.protocols import ident
153 from twisted.python import failure
154 from twisted.internet import error
155 from twisted.internet import defer
156 @@ -188,15 +178,7 @@ index d86b840e5..028778a2d 100644
157
158 from twisted.trial import unittest
159 from twisted.test.proto_helpers import StringTransport
160 -@@ -23,6 +24,7 @@ try:
161 - except ImportError:
162 - import __builtin__ as builtins
163 -
164 -+EMERGE_TEST_OVERRIDE = os.environ.get("EMERGE_TEST_OVERRIDE", False)
165 -
166 -
167 - class ClassParserTests(unittest.TestCase):
168 -@@ -216,6 +218,9 @@ class ProcMixinTests(unittest.TestCase):
169 +@@ -216,6 +216,9 @@ class ProcMixinTests(unittest.TestCase):
170 """
171 L{ident.ProcServerMixin.lookup} uses the Linux TCP process table.
172 """
173 @@ -206,26 +188,6 @@ index d86b840e5..028778a2d 100644
174 open_calls = []
175
176 def mocked_open(*args, **kwargs):
177 -diff --git a/src/twisted/test/test_main.py b/src/twisted/test/test_main.py
178 -index 572769018..60b795f96 100644
179 ---- a/src/twisted/test/test_main.py
180 -+++ b/src/twisted/test/test_main.py
181 -@@ -18,8 +18,14 @@ from twisted.trial.unittest import TestCase
182 -
183 - class MainTests(TestCase):
184 - """Test that twisted scripts can be invoked as modules."""
185 -- def test_twisted(self):
186 -+ # this test just does not work correctly on Gentoo
187 -+ # the output has '__main__.py' instead of 'trial'
188 -+ # I have only been able to get 2.7 working correctly
189 -+ # with replacing the value with what is expected.
190 -+ def _test_twisted(self):
191 - """Invoking python -m twisted should execute twist."""
192 -+ if EMERGE_TEST_OVERRIDE:
193 -+ return
194 - cmd = sys.executable
195 - p = Accumulator()
196 - d = p.endedDeferred = defer.Deferred()
197 diff --git a/src/twisted/test/test_plugin.py b/src/twisted/test/test_plugin.py
198 index a23caa72b..a6d61858c 100644
199 --- a/src/twisted/test/test_plugin.py
200 @@ -287,66 +249,6 @@ index 3d92633d6..c08809a66 100644
201 open_calls = []
202 open_rvalues = []
203
204 -diff --git a/src/twisted/test/test_reflect.py b/src/twisted/test/test_reflect.py
205 -index 5348fc65e..2f431cef7 100644
206 ---- a/src/twisted/test/test_reflect.py
207 -+++ b/src/twisted/test/test_reflect.py
208 -@@ -551,7 +551,8 @@ class SafeStrTests(TestCase):
209 - value unchanged.
210 - """
211 - x = b't\xc3\xbcst'
212 -- self.assertEqual(reflect.safe_str(x), x)
213 -+ y = [b't\xc3\xbcst', b't\\xfcst']
214 -+ self.assertEqual(reflect.safe_str(x) in y, True)
215 -
216 -
217 - def test_workingUtf8_3(self):
218 -diff --git a/src/twisted/test/test_twistd.py b/src/twisted/test/test_twistd.py
219 -index 04dc83600..654f8cba3 100644
220 ---- a/src/twisted/test/test_twistd.py
221 -+++ b/src/twisted/test/test_twistd.py
222 -@@ -78,6 +78,7 @@ if getattr(os, 'setuid', None) is None:
223 - else:
224 - setuidSkip = None
225 -
226 -+EMERGE_TEST_OVERRIDE = os.environ.get("EMERGE_TEST_OVERRIDE", False)
227 -
228 -
229 - def patchUserDatabase(patch, user, uid, group, gid):
230 -@@ -1778,9 +1779,12 @@ class DaemonizeTests(unittest.TestCase):
231 - message is Unicode, the child encodes the message as ascii
232 - with backslash Unicode code points.
233 - """
234 -- self.assertErrorWritten(raised=u"\u2022",
235 -- reported=b'1 RuntimeError: \\u2022')
236 --
237 -+ if _PY3:
238 -+ self.assertErrorWritten(raised=u"\u2022",
239 -+ reported=b'1 RuntimeError: \\u2022')
240 -+ else:
241 -+ self.assertErrorWritten(raised=u"\u2022",
242 -+ reported=b'1 RuntimeError: \xe2\x80\xa2')
243 -
244 -
245 - def assertErrorInParentBehavior(self, readData, errorMessage,
246 -@@ -1879,10 +1883,13 @@ class DaemonizeTests(unittest.TestCase):
247 - unicode and too long, it's truncated by the child, even if
248 - this splits a unicode escape sequence.
249 - """
250 -- self.assertErrorWritten(
251 -- raised=u"\u2022" * 30,
252 -- reported=b'1 RuntimeError: ' + b'\\u2022' * 14,
253 -- )
254 -+ if not EMERGE_TEST_OVERRIDE or _PY3:
255 -+ self.assertErrorWritten(
256 -+ raised=u"\u2022" * 30,
257 -+ reported=b'1 RuntimeError: ' + b'\\u2022' * 14,
258 -+ )
259 -+ else:
260 -+ pass
261 -
262 -
263 - def test_hooksCalled(self):
264 diff --git a/src/twisted/test/test_udp.py b/src/twisted/test/test_udp.py
265 index 6cf4583b2..86b513704 100644
266 --- a/src/twisted/test/test_udp.py
267
268 diff --git a/dev-python/twisted/files/utf8_overrides.patch b/dev-python/twisted/files/utf8_overrides.patch
269 new file mode 100644
270 index 00000000000..41f48cebfd8
271 --- /dev/null
272 +++ b/dev-python/twisted/files/utf8_overrides.patch
273 @@ -0,0 +1,64 @@
274 +From f8b2e95cc9bd1cbae565e1b4d576950961edc9a7 Mon Sep 17 00:00:00 2001
275 +From: Brian Dolbec <dolsen@g.o>
276 +Date: Fri, 31 Mar 2017 09:40:16 -0700
277 +Subject: [PATCH] UTF8 test overrides: The DaemonizeTests SafeStrTests tests
278 + may need to be run independantly
279 +
280 +Some other tests may leave python in a state that returns a different form of the b'\\u2022'
281 +bytestring (b'\xe2\x80\xa2') which causes the tests to fail.
282 +In StafeStrTests, the returned 't\\xfcst' != 't\xc3\xbcst' originally sent, but is just
283 +the unicode equivalent.
284 +
285 +This adds an environment override which can be used to skip these test during a full
286 +"trial twisted" run. The DaemonizeTests, SafeStrTests can then be run independantly
287 +with a clean python interpreter.
288 +---
289 + src/twisted/test/test_reflect.py | 6 ++++++
290 + src/twisted/test/test_twistd.py | 3 +++
291 + 2 files changed, 9 insertions(+)
292 +
293 +diff --git a/src/twisted/test/test_reflect.py b/src/twisted/test/test_reflect.py
294 +index ff0c7fc9e..0c13b949b 100644
295 +--- a/src/twisted/test/test_reflect.py
296 ++++ b/src/twisted/test/test_reflect.py
297 +@@ -19,6 +19,9 @@ from twisted.python.reflect import (
298 + accumulateMethods, prefixedMethods, prefixedMethodNames,
299 + addMethodNamesToDict, fullyQualifiedName)
300 +
301 ++UTF8_OVERRIDES = os.environ.get("UTF8_OVERRIDES", False)
302 ++
303 ++
304 +
305 + class Base(object):
306 + """
307 +@@ -553,6 +556,9 @@ class SafeStrTests(TestCase):
308 + x = b't\xc3\xbcst'
309 + self.assertEqual(reflect.safe_str(x), x)
310 +
311 ++ if UTF8_OVERRIDES:
312 ++ test_workingUtf8_2.skip = "test_workingUtf8_2 requires to be run independantly of other tests"
313 ++
314 +
315 + def test_workingUtf8_3(self):
316 + """
317 +diff --git a/src/twisted/test/test_twistd.py b/src/twisted/test/test_twistd.py
318 +index b74fe4a08..d55be16b9 100644
319 +--- a/src/twisted/test/test_twistd.py
320 ++++ b/src/twisted/test/test_twistd.py
321 +@@ -78,6 +78,7 @@ if getattr(os, 'setuid', None) is None:
322 + else:
323 + setuidSkip = None
324 +
325 ++UTF8_OVERRIDES = os.environ.get("UTF8_OVERRIDES", False)
326 +
327 +
328 + def patchUserDatabase(patch, user, uid, group, gid):
329 +@@ -1913,3 +1914,5 @@ class DaemonizeTests(unittest.TestCase):
330 +
331 + if _twistd_unix is None:
332 + DaemonizeTests.skip = "twistd unix support not available"
333 ++elif UTF8_OVERRIDES:
334 ++ DaemonizeTests.skip = "twistd.DaemonizeTests testing needs to be run separately"
335 +--
336 +2.12.1
337 +
338
339 diff --git a/dev-python/twisted/twisted-16.6.0.ebuild b/dev-python/twisted/twisted-16.6.0-r1.ebuild
340 similarity index 90%
341 rename from dev-python/twisted/twisted-16.6.0.ebuild
342 rename to dev-python/twisted/twisted-16.6.0-r1.ebuild
343 index e8d10cecd29..74f7447e1fb 100644
344 --- a/dev-python/twisted/twisted-16.6.0.ebuild
345 +++ b/dev-python/twisted/twisted-16.6.0-r1.ebuild
346 @@ -67,6 +67,8 @@ DEPEND="
347 PATCHES=(
348 # Respect TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE variable.
349 "${FILESDIR}/${PN}-16.5.0-respect_TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE.patch"
350 + "${FILESDIR}/test_main.patch"
351 + "${FILESDIR}/utf8_overrides.patch"
352 "${FILESDIR}/${PN}-16.6.0-test-fixes.patch"
353 )
354
355 @@ -95,6 +97,7 @@ python_test() {
356 distutils_install_for_testing
357
358 export EMERGE_TEST_OVERRIDE=1
359 + export UTF8_OVERRIDES=1
360 # workaround for the eclass not installing the entry points
361 # in the test environment. copy the old 16.3.2 start script
362 # to run the tests with
363 @@ -105,6 +108,15 @@ python_test() {
364 if ! "${TEST_DIR}"/trial twisted; then
365 die "Tests failed with ${EPYTHON}"
366 fi
367 + # due to an anomoly in the tests, python doesn't return the correct form
368 + # of the escape sequence. So run those test separately with a clean python interpreter
369 + export UTF8_OVERRIDES=0
370 + if ! "${TEST_DIR}"/trial twisted.test.test_twistd.DaemonizeTests; then
371 + die "DaemonizeTests failed with ${EPYTHON}"
372 + fi
373 + if ! "${TEST_DIR}"/trial twisted.test.test_reflect.SafeStrTests; then
374 + die "SafeStrTests failed with ${EPYTHON}"
375 + fi
376
377 popd > /dev/null || die
378 }