diff options
author | Raymond Hettinger <python@rcn.com> | 2009-06-12 11:25:59 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-06-12 11:25:59 (GMT) |
commit | 554290d9209f0a552093f03e3c8c8e512b2a0efa (patch) | |
tree | 8d183be82134946b6e4139b0ebaaefdcc889772b /Lib | |
parent | 680bf1afe89c864d6cf04a37ce1b3b2c1d60072f (diff) | |
download | cpython-554290d9209f0a552093f03e3c8c8e512b2a0efa.zip cpython-554290d9209f0a552093f03e3c8c8e512b2a0efa.tar.gz cpython-554290d9209f0a552093f03e3c8c8e512b2a0efa.tar.bz2 |
Fixup/simplify another nested context manager.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/importlib/test/import_/test_meta_path.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Lib/importlib/test/import_/test_meta_path.py b/Lib/importlib/test/import_/test_meta_path.py index 59f11d3..69859b1 100644 --- a/Lib/importlib/test/import_/test_meta_path.py +++ b/Lib/importlib/test/import_/test_meta_path.py @@ -1,6 +1,5 @@ from .. import util from . import util as import_util -from contextlib import nested from types import MethodType import unittest @@ -18,8 +17,7 @@ class CallingOrder(unittest.TestCase): mod = 'top_level' first = util.mock_modules(mod) second = util.mock_modules(mod) - context = nested(util.mock_modules(mod), util.mock_modules(mod)) - with context as (first, second): + with util.mock_modules(mod) as first, util.mock_modules(mod) as second: first.modules[mod] = 42 second.modules[mod] = -13 with util.import_state(meta_path=[first, second]): @@ -28,9 +26,8 @@ class CallingOrder(unittest.TestCase): def test_continuing(self): # [continuing] mod_name = 'for_real' - first = util.mock_modules('nonexistent') - second = util.mock_modules(mod_name) - with nested(first, second): + with util.mock_modules('nonexistent') as first, \ + util.mock_modules(mod_name) as second: first.find_module = lambda self, fullname, path=None: None second.modules[mod_name] = 42 with util.import_state(meta_path=[first, second]): |