Show More
@@ -62,9 +62,8 b' def test_parser():' | |||
|
62 | 62 | |
|
63 | 63 | def test_temp_pyfile(): |
|
64 | 64 | src = 'pass\n' |
|
65 |
fname |
|
|
65 | fname = tt.temp_pyfile(src) | |
|
66 | 66 | assert os.path.isfile(fname) |
|
67 | fh.close() | |
|
68 | 67 | with open(fname) as fh2: |
|
69 | 68 | src2 = fh2.read() |
|
70 | 69 | nt.assert_equal(src2, src) |
@@ -269,20 +269,19 b' class TempFileMixin(object):' | |||
|
269 | 269 | |
|
270 | 270 | def mktmp(self, src, ext='.py'): |
|
271 | 271 | """Make a valid python temp file.""" |
|
272 |
fname |
|
|
272 | fname = temp_pyfile(src, ext) | |
|
273 | 273 | if not hasattr(self, 'tmps'): |
|
274 | 274 | self.tmps=[] |
|
275 |
self.tmps.append( |
|
|
275 | self.tmps.append(fname) | |
|
276 | 276 | self.fname = fname |
|
277 | 277 | |
|
278 | 278 | def tearDown(self): |
|
279 | 279 | # If the tmpfile wasn't made because of skipped tests, like in |
|
280 | 280 | # win32, there's nothing to cleanup. |
|
281 | 281 | if hasattr(self, 'tmps'): |
|
282 |
for |
|
|
282 | for fname in self.tmps: | |
|
283 | 283 | # If the tmpfile wasn't made because of skipped tests, like in |
|
284 | 284 | # win32, there's nothing to cleanup. |
|
285 | f.close() | |
|
286 | 285 | try: |
|
287 | 286 | os.unlink(fname) |
|
288 | 287 | except: |
@@ -205,10 +205,10 b" def temp_pyfile(src, ext='.py'):" | |||
|
205 | 205 | It is the caller's responsibility to close the open file and unlink it. |
|
206 | 206 | """ |
|
207 | 207 | fname = tempfile.mkstemp(ext)[1] |
|
208 |
|
|
|
209 | f.write(src) | |
|
210 | f.flush() | |
|
211 |
return fname |
|
|
208 | with open(fname,'w') as f: | |
|
209 | f.write(src) | |
|
210 | f.flush() | |
|
211 | return fname | |
|
212 | 212 | |
|
213 | 213 | @undoc |
|
214 | 214 | def atomic_writing(*args, **kwargs): |
General Comments 0
You need to be logged in to leave comments.
Login now