mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-45046: Support context managers in unittest (GH-28045)
Add methods enterContext() and enterClassContext() in TestCase. Add method enterAsyncContext() in IsolatedAsyncioTestCase. Add function enterModuleContext().
This commit is contained in:
parent
8f29318079
commit
086c6b1b0f
26 changed files with 307 additions and 92 deletions
|
@ -90,14 +90,10 @@ class BaseTestCase(unittest.TestCase):
|
|||
b_check = re.compile(br"^[a-z0-9_-]{8}$")
|
||||
|
||||
def setUp(self):
|
||||
self._warnings_manager = warnings_helper.check_warnings()
|
||||
self._warnings_manager.__enter__()
|
||||
self.enterContext(warnings_helper.check_warnings())
|
||||
warnings.filterwarnings("ignore", category=RuntimeWarning,
|
||||
message="mktemp", module=__name__)
|
||||
|
||||
def tearDown(self):
|
||||
self._warnings_manager.__exit__(None, None, None)
|
||||
|
||||
def nameCheck(self, name, dir, pre, suf):
|
||||
(ndir, nbase) = os.path.split(name)
|
||||
npre = nbase[:len(pre)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue