Skip to content

Commit f6ecaa9

Browse files
committed
Fix ResourceWarning: unclosed file in setup.py
Also uniformize the usage of the 'with' context manager. Signed-off-by: Mickaël Schoentgen <[email protected]>
1 parent ccdb36a commit f6ecaa9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
install_requires = ["execnet>=1.1", "pytest>=3.6.0", "pytest-forked", "six"]
44

55

6+
with open("README.rst") as f:
7+
long_description = f.read()
8+
69
setup(
710
name="pytest-xdist",
811
use_scm_version={"write_to": "xdist/_version.py"},
912
description="pytest xdist plugin for distributed testing"
1013
" and loop-on-failing modes",
11-
long_description=open("README.rst").read(),
14+
long_description=long_description,
1215
license="MIT",
1316
author="holger krekel and contributors",
1417

testing/acceptance_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,8 @@ def pytest_sessionfinish(session):
490490
name = "worker"
491491
else:
492492
name = "master"
493-
f = open(name, "w")
494-
f.write("xy")
495-
f.close()
493+
with open(name, "w") as f:
494+
f.write("xy")
496495
# let's fail on the worker
497496
if name == "worker":
498497
raise ValueError(42)

0 commit comments

Comments
 (0)