Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d656354

Browse files
author
Victor Stinner
committed
Fix test_warnings on Windows (don't change current directory)
1 parent 148051a commit d656354

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

Lib/test/test_warnings.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from io import StringIO
55
import sys
66
import unittest
7-
import shutil
87
import tempfile
98
import subprocess
109
from test import support
@@ -678,12 +677,11 @@ def test_issue_8766(self):
678677
# "import encodings" emits a warning whereas the warnings is not loaded
679678
# or not completly loaded (warnings imports indirectly encodings by
680679
# importing linecache) yet
681-
old_cwd = os.getcwd()
680+
cwd = tempfile.mkdtemp()
682681
try:
683-
cwd = tempfile.mkdtemp()
682+
encodings = os.path.join(cwd, 'encodings')
683+
os.mkdir(encodings)
684684
try:
685-
os.chdir(cwd)
686-
os.mkdir('encodings')
687685
env = os.environ.copy()
688686
env['PYTHONPATH'] = cwd
689687

@@ -697,9 +695,9 @@ def test_issue_8766(self):
697695
env=env)
698696
self.assertEqual(retcode, 0)
699697
finally:
700-
shutil.rmtree(cwd)
698+
os.rmdir(encodings)
701699
finally:
702-
os.chdir(old_cwd)
700+
os.rmdir(cwd)
703701

704702
def test_main():
705703
py_warnings.onceregistry.clear()

0 commit comments

Comments
 (0)