mirror of https://github.com/python/cpython
Avoid replacing existing modules and sys.path in import tests
This commit is contained in:
parent
8157e19e8f
commit
788d7667cb
|
@ -43,14 +43,17 @@ class ReloadTests(unittest.TestCase):
|
|||
reload()."""
|
||||
|
||||
def test_source(self):
|
||||
with test_support.CleanImport('os'):
|
||||
import os
|
||||
imp.reload(os)
|
||||
|
||||
def test_extension(self):
|
||||
with test_support.CleanImport('time'):
|
||||
import time
|
||||
imp.reload(time)
|
||||
|
||||
def test_builtin(self):
|
||||
with test_support.CleanImport('marshal'):
|
||||
import marshal
|
||||
imp.reload(marshal)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import py_compile
|
|||
import warnings
|
||||
import marshal
|
||||
from test.test_support import (unlink, TESTFN, unload, run_unittest,
|
||||
check_warnings, TestFailed)
|
||||
check_warnings, TestFailed, CleanImport)
|
||||
|
||||
|
||||
def remove_files(name):
|
||||
|
@ -122,6 +122,7 @@ class ImportTest(unittest.TestCase):
|
|||
def testImpModule(self):
|
||||
# Verify that the imp module can correctly load and find .py files
|
||||
import imp
|
||||
with CleanImport("os"):
|
||||
x = imp.find_module("os")
|
||||
os = imp.load_module("os", *x)
|
||||
|
||||
|
@ -361,7 +362,7 @@ class PathsTests(unittest.TestCase):
|
|||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.path)
|
||||
sys.path = self.syspath
|
||||
sys.path[:] = self.syspath
|
||||
|
||||
# http://bugs.python.org/issue1293
|
||||
def test_trailing_slash(self):
|
||||
|
|
Loading…
Reference in New Issue