From 58533a71b2de37c6b3b5dbd645e6b1b6702a4aff Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 10 May 2019 12:26:20 -0400 Subject: [PATCH] Refresh from importlib_metadata@cpython --- Lib/test/test_importlib/fixtures.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_importlib/fixtures.py b/Lib/test/test_importlib/fixtures.py index 737ea4be7aa39f..00fcffa9d92d98 100644 --- a/Lib/test/test_importlib/fixtures.py +++ b/Lib/test/test_importlib/fixtures.py @@ -24,11 +24,9 @@ @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() -