]> granicus.if.org Git - python/commitdiff
Fix test_warnings on Windows (don't change current directory)
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 20 May 2010 21:42:00 +0000 (21:42 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 20 May 2010 21:42:00 +0000 (21:42 +0000)
Lib/test/test_warnings.py

index 5cf1034a5da524f7e1f97ed6771ae89b272510cb..85b5cad239d5317e370ca383f24f25d372108382 100644 (file)
@@ -4,7 +4,6 @@ import os
 from io import StringIO
 import sys
 import unittest
-import shutil
 import tempfile
 import subprocess
 from test import support
@@ -678,12 +677,11 @@ class BootstrapTest(unittest.TestCase):
         # "import encodings" emits a warning whereas the warnings is not loaded
         # or not completly loaded (warnings imports indirectly encodings by
         # importing linecache) yet
-        old_cwd = os.getcwd()
+        cwd = tempfile.mkdtemp()
         try:
-            cwd = tempfile.mkdtemp()
+            encodings = os.path.join(cwd, 'encodings')
+            os.mkdir(encodings)
             try:
-                os.chdir(cwd)
-                os.mkdir('encodings')
                 env = os.environ.copy()
                 env['PYTHONPATH'] = cwd
 
@@ -697,9 +695,9 @@ class BootstrapTest(unittest.TestCase):
                     env=env)
                 self.assertEqual(retcode, 0)
             finally:
-                shutil.rmtree(cwd)
+                os.rmdir(encodings)
         finally:
-            os.chdir(old_cwd)
+            os.rmdir(cwd)
 
 def test_main():
     py_warnings.onceregistry.clear()