From: Jason R. Coombs Date: Fri, 10 May 2019 16:26:20 +0000 (-0400) Subject: Refresh from importlib_metadata@cpython X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58533a71b2de37c6b3b5dbd645e6b1b6702a4aff;p=thirdparty%2FPython%2Fcpython.git Refresh from importlib_metadata@cpython --- diff --git a/Lib/test/test_importlib/fixtures.py b/Lib/test/test_importlib/fixtures.py index 737ea4be7aa3..00fcffa9d92d 100644 --- a/Lib/test/test_importlib/fixtures.py +++ b/Lib/test/test_importlib/fixtures.py @@ -24,11 +24,9 @@ __metaclass__ = type @contextlib.contextmanager def tempdir(): tmpdir = tempfile.mkdtemp() - sys.path[:0] = [tmpdir] try: yield pathlib.Path(tmpdir) finally: - sys.path.remove(tmpdir) shutil.rmtree(tmpdir) @@ -55,7 +53,10 @@ class SiteDir: def site_dir(): with tempdir() as tmp: sys.path[:0] = [str(tmp)] - yield tmp + try: + yield tmp + finally: + sys.path.remove(str(tmp)) def setUp(self): self.fixtures = ExitStack() @@ -193,4 +194,3 @@ def build_files(file_defs, prefix=pathlib.Path()): def DALS(str): "Dedent and left-strip" return textwrap.dedent(str).lstrip() -