mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
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...
This commit is contained in:
parent
83f1ef681f
commit
9039b83c53
2 changed files with 24 additions and 5 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue