Fix test_novice.test_update_on_save failure on Windows

On Windows, tempfile.NamedTemporaryFile() can not be opened a second time. See <http://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile>
This commit is contained in:
cgohlke
2014-03-10 22:22:02 -07:00
parent f4b260cb33
commit 534721126b
+7 -3
View File
@@ -111,12 +111,16 @@ def test_update_on_save():
assert pic.modified
assert pic.path is None
with tempfile.NamedTemporaryFile(suffix=".jpg") as tmp:
pic.save(tmp.name)
fd, filename = tempfile.mkstemp(suffix=".jpg")
os.close(fd)
try:
pic.save(filename)
assert not pic.modified
assert_equal(pic.path, os.path.abspath(tmp.name))
assert_equal(pic.path, os.path.abspath(filename))
assert_equal(pic.format, "jpeg")
finally:
os.unlink(filename)
def test_indexing():