summaryrefslogtreecommitdiff
path: root/Lib/test/test_imp.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2009-10-18 05:38:48 +0000
committerNick Coghlan <ncoghlan@gmail.com>2009-10-18 05:38:48 +0000
commit9039b83c534251d8a28a16ac25fac20c17382945 (patch)
treeb4dbf28fbea47f546b26787ca9db1e4c021aa20f /Lib/test/test_imp.py
parent83f1ef681ff2f0c393bc79bd0c1ccdb558634be4 (diff)
downloadcpython-git-9039b83c534251d8a28a16ac25fac20c17382945.tar.gz
Using CleanImport to revert a reload of the os module doesn't work due to function registrations in copy_reg. The perils of reloading modules even for tests...
Diffstat (limited to 'Lib/test/test_imp.py')
-rw-r--r--Lib/test/test_imp.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index 1e62940939..77e44bec92 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -43,7 +43,14 @@ class ReloadTests(unittest.TestCase):
reload()."""
def test_source(self):
- with test_support.CleanImport('os'):
+ # XXX (ncoghlan): It would be nice to use test_support.CleanImport
+ # here, but that breaks because the os module registers some
+ # handlers in copy_reg on import. Since CleanImport doesn't
+ # revert that registration, the module is left in a broken
+ # state after reversion. Reinitialising the module contents
+ # and just reverting os.environ to its previous state is an OK
+ # workaround
+ with test_support.EnvironmentVarGuard():
import os
imp.reload(os)