use auto-close in writethings test
@@ -6,17 +6,15 @@ content = "hello"
# guaranteed to be deleted on close and/or garbage collection
with tempfile.NamedTemporaryFile() as tmpfile:
- writer = createOutput(tmpfile.name)
+ with createOutput(tmpfile.name) as writer:
saveBytes(writer, content)
- tmpfile.flush()
- reader = createInput(tmpfile.name)
+ with createInput(tmpfile.name) as reader:
data = loadBytes(reader)
assert ''.join([chr(c) for c in data]) == content
- writer = createOutput(File(tmpfile.name))
+ with createOutput(File(tmpfile.name)) as writer:
saveBytes(writer, content)
- tmpfile.flush()
- reader = createInput(tmpfile.name)
+ with createInput(tmpfile.name) as reader:
data = loadBytes(reader)
assert ''.join([chr(c) for c in data]) == content
