MCPcopy Create free account
hub / github.com/EasyIME/PIME / setup_with_context_manager

Function setup_with_context_manager

python/python3/tornado/testing.py:789–793  ·  view source on GitHub ↗

Use a contextmanager to setUp a test case.

(testcase: unittest.TestCase, cm: Any)

Source from the content-addressed store, hash-verified

787
788# From https://nedbatchelder.com/blog/201508/using_context_managers_in_test_setup.html
789def setup_with_context_manager(testcase: unittest.TestCase, cm: Any) -> Any:
790 """Use a contextmanager to setUp a test case."""
791 val = cm.__enter__()
792 testcase.addCleanup(cm.__exit__, None, None, None)
793 return val
794
795
796def main(**kwargs: Any) -> None:

Callers 3

setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.85

Calls 1

__enter__Method · 0.45

Tested by

no test coverage detected