Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 554290d

Browse files
committed
Fixup/simplify another nested context manager.
1 parent 680bf1a commit 554290d

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

Lib/importlib/test/import_/test_meta_path.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from .. import util
22
from . import util as import_util
3-
from contextlib import nested
43
from types import MethodType
54
import unittest
65

@@ -18,8 +17,7 @@ def test_first_called(self):
1817
mod = 'top_level'
1918
first = util.mock_modules(mod)
2019
second = util.mock_modules(mod)
21-
context = nested(util.mock_modules(mod), util.mock_modules(mod))
22-
with context as (first, second):
20+
with util.mock_modules(mod) as first, util.mock_modules(mod) as second:
2321
first.modules[mod] = 42
2422
second.modules[mod] = -13
2523
with util.import_state(meta_path=[first, second]):
@@ -28,9 +26,8 @@ def test_first_called(self):
2826
def test_continuing(self):
2927
# [continuing]
3028
mod_name = 'for_real'
31-
first = util.mock_modules('nonexistent')
32-
second = util.mock_modules(mod_name)
33-
with nested(first, second):
29+
with util.mock_modules('nonexistent') as first, \
30+
util.mock_modules(mod_name) as second:
3431
first.find_module = lambda self, fullname, path=None: None
3532
second.modules[mod_name] = 42
3633
with util.import_state(meta_path=[first, second]):

0 commit comments

Comments
 (0)