mirror of https://github.com/python/cpython
Implement #7944. Use `with` throughout the test suite.
This commit is contained in:
parent
5acec04db5
commit
2c3563f782
|
@ -11,16 +11,10 @@ class HelperMixin:
|
||||||
new = marshal.loads(marshal.dumps(sample, *extra))
|
new = marshal.loads(marshal.dumps(sample, *extra))
|
||||||
self.assertEqual(sample, new)
|
self.assertEqual(sample, new)
|
||||||
try:
|
try:
|
||||||
f = open(support.TESTFN, "wb")
|
with open(support.TESTFN, "wb") as f:
|
||||||
try:
|
|
||||||
marshal.dump(sample, f, *extra)
|
marshal.dump(sample, f, *extra)
|
||||||
finally:
|
with open(support.TESTFN, "rb") as f:
|
||||||
f.close()
|
|
||||||
f = open(support.TESTFN, "rb")
|
|
||||||
try:
|
|
||||||
new = marshal.load(f)
|
new = marshal.load(f)
|
||||||
finally:
|
|
||||||
f.close()
|
|
||||||
self.assertEqual(sample, new)
|
self.assertEqual(sample, new)
|
||||||
finally:
|
finally:
|
||||||
support.unlink(support.TESTFN)
|
support.unlink(support.TESTFN)
|
||||||
|
|
Loading…
Reference in New Issue