mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix test_warnings on Windows (don't change current directory)
This commit is contained in:
parent
148051a054
commit
d656354ddd
1 changed files with 5 additions and 7 deletions
|
@ -4,7 +4,6 @@ import os
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
import shutil
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
from test import support
|
from test import support
|
||||||
|
@ -678,12 +677,11 @@ class BootstrapTest(unittest.TestCase):
|
||||||
# "import encodings" emits a warning whereas the warnings is not loaded
|
# "import encodings" emits a warning whereas the warnings is not loaded
|
||||||
# or not completly loaded (warnings imports indirectly encodings by
|
# or not completly loaded (warnings imports indirectly encodings by
|
||||||
# importing linecache) yet
|
# importing linecache) yet
|
||||||
old_cwd = os.getcwd()
|
cwd = tempfile.mkdtemp()
|
||||||
try:
|
try:
|
||||||
cwd = tempfile.mkdtemp()
|
encodings = os.path.join(cwd, 'encodings')
|
||||||
|
os.mkdir(encodings)
|
||||||
try:
|
try:
|
||||||
os.chdir(cwd)
|
|
||||||
os.mkdir('encodings')
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env['PYTHONPATH'] = cwd
|
env['PYTHONPATH'] = cwd
|
||||||
|
|
||||||
|
@ -697,9 +695,9 @@ class BootstrapTest(unittest.TestCase):
|
||||||
env=env)
|
env=env)
|
||||||
self.assertEqual(retcode, 0)
|
self.assertEqual(retcode, 0)
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(cwd)
|
os.rmdir(encodings)
|
||||||
finally:
|
finally:
|
||||||
os.chdir(old_cwd)
|
os.rmdir(cwd)
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
py_warnings.onceregistry.clear()
|
py_warnings.onceregistry.clear()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue