]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Refresh from importlib_metadata@cpython
authorJason R. Coombs <jaraco@jaraco.com>
Fri, 10 May 2019 16:26:20 +0000 (12:26 -0400)
committerJason R. Coombs <jaraco@jaraco.com>
Fri, 10 May 2019 16:26:20 +0000 (12:26 -0400)
Lib/test/test_importlib/fixtures.py

index 737ea4be7aa39ffa32ec0a7a589cefa7dba8625d..00fcffa9d92d9892fa25ffae764365ff8bd11706 100644 (file)
@@ -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()
-