Fix ResourceWarning: unclosed file in setup.py

Also uniformize the usage of the 'with' context manager.

Signed-off-by: Mickaël Schoentgen <contact@tiger-222.fr>
This commit is contained in:
Mickaël Schoentgen
2019-01-14 22:59:33 +01:00
parent ccdb36a477
commit f6ecaa9b7f
2 changed files with 6 additions and 4 deletions

View File

@@ -490,9 +490,8 @@ def test_session_hooks(testdir):
name = "worker"
else:
name = "master"
f = open(name, "w")
f.write("xy")
f.close()
with open(name, "w") as f:
f.write("xy")
# let's fail on the worker
if name == "worker":
raise ValueError(42)