Merge ~cjwatson/launchpad:py3-parallel-testing into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 50ac32605db9a3e75b7d6e8091ac510e4d4aa1d5
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-parallel-testing
Merge into: launchpad:master
Diff against target: 63 lines (+7/-6)
2 files modified
lib/lp/services/testing/parallel.py (+1/-1)
lib/lp/services/testing/tests/test_parallel.py (+6/-5)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+393810@code.launchpad.net

Commit message

Fix parallel testing machinery on Python 3

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/testing/parallel.py b/lib/lp/services/testing/parallel.py
2index b169b0f..e5fb710 100644
3--- a/lib/lp/services/testing/parallel.py
4+++ b/lib/lp/services/testing/parallel.py
5@@ -104,7 +104,7 @@ class ListTestCase(ProtocolTestCase):
6 self._args = args
7
8 def run(self, result):
9- with tempfile.NamedTemporaryFile() as test_list_file:
10+ with tempfile.NamedTemporaryFile(mode='w+') as test_list_file:
11 for test_id in self._test_ids:
12 test_list_file.write(test_id + '\n')
13 test_list_file.flush()
14diff --git a/lib/lp/services/testing/tests/test_parallel.py b/lib/lp/services/testing/tests/test_parallel.py
15index f8afd34..7e83670 100644
16--- a/lib/lp/services/testing/tests/test_parallel.py
17+++ b/lib/lp/services/testing/tests/test_parallel.py
18@@ -5,6 +5,7 @@
19
20 __metaclass__ = type
21
22+import io
23 import subprocess
24 import tempfile
25 from textwrap import dedent
26@@ -41,7 +42,7 @@ class TestListTestCase(TestCase, TestWithFixtures):
27 with open(load_list, 'rt') as testlist:
28 contents = testlist.readlines()
29 self.assertEqual(['foo\n', 'bar\n'], contents)
30- return {'stdout': six.StringIO(), 'stdin': six.StringIO()}
31+ return {'stdout': io.BytesIO(), 'stdin': io.BytesIO()}
32 popen = self.useFixture(PopenFixture(check_list_file))
33 case = ListTestCase(['foo', 'bar'], ['bin/test'])
34 self.assertEqual([], popen.procs)
35@@ -76,7 +77,7 @@ class TestUtilities(TestCase, TestWithFixtures):
36 prepare_argv(['bin/test', '--load-list', 'Foo', 'foo']))
37
38 def test_find_tests_honours_list_list_equals(self):
39- with tempfile.NamedTemporaryFile() as listfile:
40+ with tempfile.NamedTemporaryFile(mode='w+') as listfile:
41 listfile.write('foo\nbar\n')
42 listfile.flush()
43 self.assertEqual(
44@@ -85,7 +86,7 @@ class TestUtilities(TestCase, TestWithFixtures):
45 ['bin/test', '--load-list=%s' % listfile.name, 'foo']))
46
47 def test_find_tests_honours_list_list_two_arg_form(self):
48- with tempfile.NamedTemporaryFile() as listfile:
49+ with tempfile.NamedTemporaryFile(mode='w+') as listfile:
50 listfile.write('foo\nbar\n')
51 listfile.flush()
52 self.assertEqual(
53@@ -104,8 +105,8 @@ class TestUtilities(TestCase, TestWithFixtures):
54 ['bin/test', '-vt', 'filter', '--list-tests', '--subunit'],
55 args['args'])
56 return {
57- 'stdin': six.StringIO(),
58- 'stdout': six.StringIO(six.ensure_str(dedent("""\
59+ 'stdin': io.BytesIO(),
60+ 'stdout': io.BytesIO(six.ensure_binary(dedent("""\
61 test: quux
62 successful: quux
63 test: glom

Subscribers

People subscribed via source and target branches

to status/vote changes: