Skip to content

Commit

Permalink
Fix test failures on Windows
Browse files Browse the repository at this point in the history
See https://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile
for details (the temp file cannot be opened a second time on Windows).
  • Loading branch information
mgedmin committed Dec 27, 2014
1 parent 1dfea39 commit e916481
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/zope/ptresource/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ def setUp(self):
def tearDown(self):
super(Test, self).tearDown()
if self._test_file is not None:
self._test_file.close()
os.unlink(self._test_file)

def createTestFile(self, contents):
f = self._test_file = tempfile.NamedTemporaryFile(mode='w+')
f = tempfile.NamedTemporaryFile(mode='w', delete=False)
f.write(contents)
f.flush()
f.close()
self._test_file = f.name
return f.name

def testNoTraversal(self):
Expand Down

0 comments on commit e916481

Please sign in to comment.