summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_import.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index d30f905..dbfadfb7 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -46,13 +46,12 @@ class ImportTest(unittest.TestCase):
else:
pyc = TESTFN + ".pyc"
- f = open(source, "w")
- print("# This tests Python's ability to import a", ext, "file.", file=f)
- a = random.randrange(1000)
- b = random.randrange(1000)
- print("a =", a, file=f)
- print("b =", b, file=f)
- f.close()
+ with open(source, "w") as f:
+ print("# This tests Python's ability to import a", ext, "file.", file=f)
+ a = random.randrange(1000)
+ b = random.randrange(1000)
+ print("a =", a, file=f)
+ print("b =", b, file=f)
if TESTFN in sys.modules:
del sys.modules[TESTFN]