Unit Tests: Temporary file handles need to be closed explicitly under Windows

This commit is contained in:
Stefan Bisplinghoff 2017-03-16 16:16:46 +01:00
parent f6d11937b4
commit f0c066af0f
2 changed files with 4 additions and 2 deletions

View file

@ -134,13 +134,14 @@ class TestSequenceFunctions(unittest.TestCase):
def test_atomFeedFile(self): def test_atomFeedFile(self):
fg = self.fg fg = self.fg
_, filename = tempfile.mkstemp() fh, filename = tempfile.mkstemp()
fg.atom_file(filename=filename, pretty=True, xml_declaration=False) fg.atom_file(filename=filename, pretty=True, xml_declaration=False)
with open(filename, "r") as myfile: with open(filename, "r") as myfile:
atomString = myfile.read().replace('\n', '') atomString = myfile.read().replace('\n', '')
self.checkAtomString(atomString) self.checkAtomString(atomString)
os.close(fh)
os.remove(filename) os.remove(filename)
def test_atomFeedString(self): def test_atomFeedString(self):

View file

@ -31,10 +31,11 @@ class TestSequenceFunctions(unittest.TestCase):
def test_file(self): def test_file(self):
for extemsion in '.atom', '.rss': for extemsion in '.atom', '.rss':
_, filename = tempfile.mkstemp(extemsion) fh, filename = tempfile.mkstemp(extemsion)
sys.argv = ['feedgen', filename] sys.argv = ['feedgen', filename]
try: try:
__main__.main() __main__.main()
except: except:
assert False assert False
os.close(fh)
os.remove(filename) os.remove(filename)