From f6ecaa9b7f33031d571cca44efa74a02e00dcff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Mon, 14 Jan 2019 22:59:33 +0100 Subject: [PATCH] Fix ResourceWarning: unclosed file in setup.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also uniformize the usage of the 'with' context manager. Signed-off-by: Mickaƫl Schoentgen --- setup.py | 5 ++++- testing/acceptance_test.py | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index b830492..03ee47a 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,15 @@ from setuptools import setup, find_packages install_requires = ["execnet>=1.1", "pytest>=3.6.0", "pytest-forked", "six"] +with open("README.rst") as f: + long_description = f.read() + setup( name="pytest-xdist", use_scm_version={"write_to": "xdist/_version.py"}, description="pytest xdist plugin for distributed testing" " and loop-on-failing modes", - long_description=open("README.rst").read(), + long_description=long_description, license="MIT", author="holger krekel and contributors", author_email="pytest-dev@python.org,holger@merlinux.eu", diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index e0d4770..9a8e42b 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -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)