Merge lp:~jml/python-fixtures/misc-fixes into lp:~python-fixtures/python-fixtures/trunk

Proposed by Jonathan Lange
Status: Merged
Merged at revision: 29
Proposed branch: lp:~jml/python-fixtures/misc-fixes
Merge into: lp:~python-fixtures/python-fixtures/trunk
Diff against target: 221 lines (+34/-21)
8 files modified
.bzrignore (+1/-0)
NEWS (+7/-0)
README (+9/-9)
lib/fixtures/_fixtures/pythonpackage.py (+2/-2)
lib/fixtures/fixture.py (+3/-2)
lib/fixtures/testcase.py (+1/-1)
lib/fixtures/tests/_fixtures/test_popen.py (+6/-3)
lib/fixtures/tests/_fixtures/test_pythonpackage.py (+5/-4)
To merge this branch: bzr merge lp:~jml/python-fixtures/misc-fixes
Reviewer Review Type Date Requested Status
python-fixtures committers Pending
Review via email: mp+69376@code.launchpad.net

Description of the change

 * Work with testtools trunk, post API change requested by fixtures
 * Work with Python 3, provided that https://code.launchpad.net/~jml/testtools/reraise/+merge/69375 has been merged into aforementioned testtools trunk

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Cool.

Needs a NEWS entry and a README update about the dependency version,

Revision history for this message
Jonathan Lange (jml) wrote :

Done. Should probably wait until https://code.launchpad.net/~jml/testtools/reraise/+merge/69375 is reviewed & merged before landing this.

lp:~jml/python-fixtures/misc-fixes updated
32. By Jonathan Lange

NEWS & README.

Revision history for this message
Jonathan Lange (jml) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2010-08-15 09:01:23 +0000
3+++ .bzrignore 2011-07-27 00:08:32 +0000
4@@ -4,3 +4,4 @@
5 MANIFEST
6 dist
7 .testrepository
8+__pycache__
9
10=== modified file 'NEWS'
11--- NEWS 2011-06-23 08:21:10 +0000
12+++ NEWS 2011-07-27 00:08:32 +0000
13@@ -6,6 +6,13 @@
14 IN DEVELOPMENT
15 ~~~~~~~~~~~~~~
16
17+CHANGES:
18+
19+* Python 3 now supported. (Jonathan Lange, #816665)
20+
21+* Updated to match the changed ``gather_details`` API in testtools. See #801027.
22+ (Jonathan Lange)
23+
24 0.3.6
25 ~~~~~
26
27
28=== modified file 'README'
29--- README 2011-06-23 05:54:36 +0000
30+++ README 2011-07-27 00:08:32 +0000
31@@ -28,7 +28,7 @@
32 * Python 2.4+
33 This is the base language fixtures is written in and for.
34
35-* testtools <https://launchpad.net/testtools> 0.9.8 or newer.
36+* testtools <https://launchpad.net/testtools> 0.9.12 or newer.
37 testtools provides helpful glue functions for the details API used to report
38 information about a fixture (whether its used in a testing or production
39 environment).
40@@ -99,7 +99,7 @@
41 ... shutil.rmtree(fixture)
42 >>> fixture = fixtures.FunctionFixture(setup_function, teardown_function)
43 >>> fixture.setUp()
44- >>> print os.path.isdir(fixture.fn_result)
45+ >>> print (os.path.isdir(fixture.fn_result))
46 True
47 >>> fixture.cleanUp()
48
49@@ -107,7 +107,7 @@
50
51 >>> fixture = fixtures.FunctionFixture(tempfile.mkdtemp, shutil.rmtree)
52 >>> fixture.setUp()
53- >>> print os.path.isdir(fixture.fn_result)
54+ >>> print (os.path.isdir(fixture.fn_result))
55 True
56 >>> fixture.cleanUp()
57
58@@ -159,14 +159,14 @@
59 ... self.assertEqual(42, fixture.frobnozzle)
60 >>> result = unittest.TestResult()
61 >>> _ = NoddyTest('test_example').run(result)
62- >>> print result.wasSuccessful()
63+ >>> print (result.wasSuccessful())
64 True
65
66 Fixtures implement the context protocol, so you can also use a fixture as a
67 context manager::
68
69 >>> with fixtures.FunctionFixture(setup_function, teardown_function) as fixture:
70- ... print os.path.isdir(fixture.fn_result)
71+ ... print (os.path.isdir(fixture.fn_result))
72 True
73
74 When multiple cleanups error, fixture.cleanUp() will raise a wrapper exception
75@@ -185,8 +185,8 @@
76 ... fixture.cleanUp()
77 ... except MultipleExceptions:
78 ... exc_info = sys.exc_info()
79- >>> print exc_info[1].args[0][0]
80- <type 'exceptions.ZeroDivisionError'>
81+ >>> print (exc_info[1].args[0][0].__name__)
82+ ZeroDivisionError
83
84 Shared Dependencies
85 +++++++++++++++++++
86@@ -298,8 +298,8 @@
87 Pretend to run an external command rather than needing it to be present to run
88 tests.
89
90- >>> from StringIO import StringIO
91- >>> fixture = fixtures.PopenFixture(lambda _:{'stdout': StringIO('foobar')})
92+ >>> from testtools.compat import BytesIO
93+ >>> fixture = fixtures.PopenFixture(lambda _:{'stdout': BytesIO('foobar')})
94
95 PythonPackage
96 +++++++++++++
97
98=== modified file 'lib/fixtures/_fixtures/pythonpackage.py'
99--- lib/fixtures/_fixtures/pythonpackage.py 2010-11-07 01:48:22 +0000
100+++ lib/fixtures/_fixtures/pythonpackage.py 2011-07-27 00:08:32 +0000
101@@ -55,7 +55,7 @@
102 os.mkdir(root)
103 init_seen = not self.init
104 for modulename, contents in self.modulelist:
105- stream = file(os.path.join(root, modulename), 'wb')
106+ stream = open(os.path.join(root, modulename), 'wb')
107 try:
108 stream.write(contents)
109 finally:
110@@ -63,4 +63,4 @@
111 if modulename == '__init__.py':
112 init_seen = True
113 if not init_seen:
114- file(os.path.join(root, '__init__.py'), 'wb').close()
115+ open(os.path.join(root, '__init__.py'), 'wb').close()
116
117=== modified file 'lib/fixtures/fixture.py'
118--- lib/fixtures/fixture.py 2011-06-23 07:56:42 +0000
119+++ lib/fixtures/fixture.py 2011-07-27 00:08:32 +0000
120@@ -23,6 +23,7 @@
121 import itertools
122 import sys
123
124+from testtools.compat import reraise
125 from testtools.helpers import try_import
126
127 class MultipleExceptions(Exception):
128@@ -115,7 +116,7 @@
129 if result and raise_first:
130 if 1 == len(result):
131 error = result[0]
132- raise error[0], error[1], error[2]
133+ reraise(error[0], error[1], error[2])
134 else:
135 raise MultipleExceptions(*result)
136 if not raise_first:
137@@ -199,7 +200,7 @@
138 # The child failed to come up, capture any details it has (copying
139 # the content, it may go away anytime).
140 if gather_details is not None:
141- gather_details(fixture, self)
142+ gather_details(fixture.getDetails(), self._details)
143 raise
144 else:
145 self.addCleanup(fixture.cleanUp)
146
147=== modified file 'lib/fixtures/testcase.py'
148--- lib/fixtures/testcase.py 2011-06-23 07:56:42 +0000
149+++ lib/fixtures/testcase.py 2011-07-27 00:08:32 +0000
150@@ -45,7 +45,7 @@
151 except:
152 if use_details:
153 # Capture the details now, in case the fixture goes away.
154- gather_details(fixture, self)
155+ gather_details(fixture.getDetails(), self.getDetails())
156 raise
157 else:
158 self.addCleanup(fixture.cleanUp)
159
160=== modified file 'lib/fixtures/tests/_fixtures/test_popen.py'
161--- lib/fixtures/tests/_fixtures/test_popen.py 2010-10-15 02:41:18 +0000
162+++ lib/fixtures/tests/_fixtures/test_popen.py 2011-07-27 00:08:32 +0000
163@@ -13,10 +13,13 @@
164 # license you chose for the specific language governing permissions and
165 # limitations under that license.
166
167-import StringIO
168 import subprocess
169
170 import testtools
171+from testtools.compat import (
172+ _b,
173+ BytesIO,
174+ )
175
176 import fixtures
177 from fixtures import PopenFixture, TestWithFixtures
178@@ -63,6 +66,6 @@
179 self.assertEqual(0, proc.returncode)
180
181 def test_communicate_with_out(self):
182- proc = FakeProcess({}, {'stdout': StringIO.StringIO('foo')})
183- self.assertEqual(('foo', ''), proc.communicate())
184+ proc = FakeProcess({}, {'stdout': BytesIO(_b('foo'))})
185+ self.assertEqual((_b('foo'), ''), proc.communicate())
186 self.assertEqual(0, proc.returncode)
187
188=== modified file 'lib/fixtures/tests/_fixtures/test_pythonpackage.py'
189--- lib/fixtures/tests/_fixtures/test_pythonpackage.py 2010-11-07 01:48:22 +0000
190+++ lib/fixtures/tests/_fixtures/test_pythonpackage.py 2011-07-27 00:08:32 +0000
191@@ -16,6 +16,7 @@
192 import os.path
193
194 import testtools
195+from testtools.compat import _b
196
197 import fixtures
198 from fixtures import PythonPackage, TempDir, TestWithFixtures
199@@ -32,18 +33,18 @@
200 fixture.cleanUp()
201
202 def test_writes_package(self):
203- fixture = PythonPackage('foo', [('bar.py', 'woo')])
204+ fixture = PythonPackage('foo', [('bar.py', _b('woo'))])
205 fixture.setUp()
206 try:
207- self.assertEqual('', file(os.path.join(fixture.base, 'foo',
208+ self.assertEqual('', open(os.path.join(fixture.base, 'foo',
209 '__init__.py')).read())
210- self.assertEqual('woo', file(os.path.join(fixture.base, 'foo',
211+ self.assertEqual('woo', open(os.path.join(fixture.base, 'foo',
212 'bar.py')).read())
213 finally:
214 fixture.cleanUp()
215
216 def test_no__init__(self):
217- fixture = PythonPackage('foo', [('bar.py', 'woo')], init=False)
218+ fixture = PythonPackage('foo', [('bar.py', _b('woo'))], init=False)
219 fixture.setUp()
220 try:
221 self.assertFalse(os.path.exists(os.path.join(fixture.base, 'foo',

Subscribers

People subscribed via source and target branches