mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +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
|
@ -1022,8 +1022,7 @@ class TestBasicOpsBytes(TestBasicOps, unittest.TestCase):
|
|||
|
||||
class TestBasicOpsMixedStringBytes(TestBasicOps, unittest.TestCase):
|
||||
def setUp(self):
|
||||
self._warning_filters = warnings_helper.check_warnings()
|
||||
self._warning_filters.__enter__()
|
||||
self.enterContext(warnings_helper.check_warnings())
|
||||
warnings.simplefilter('ignore', BytesWarning)
|
||||
self.case = "string and bytes set"
|
||||
self.values = ["a", "b", b"a", b"b"]
|
||||
|
@ -1031,9 +1030,6 @@ class TestBasicOpsMixedStringBytes(TestBasicOps, unittest.TestCase):
|
|||
self.dup = set(self.values)
|
||||
self.length = 4
|
||||
|
||||
def tearDown(self):
|
||||
self._warning_filters.__exit__(None, None, None)
|
||||
|
||||
def test_repr(self):
|
||||
self.check_repr_against_values()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue