Skip to content

Commit

Permalink
test.util: Remove our private compatibility shim for subTests
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Jul 11, 2024
1 parent ef8c6ab commit 77e0a4f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
3 changes: 1 addition & 2 deletions tornado/test/options_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from tornado.options import OptionParser, Error
from tornado.util import basestring_type
from tornado.test.util import subTest

import typing

Expand Down Expand Up @@ -277,7 +276,7 @@ def test_error_redefine_underscore(self):
("foo_bar", "foo-bar"),
]
for a, b in tests:
with subTest(self, a=a, b=b):
with self.subTest(self, a=a, b=b):
options = OptionParser()
options.define(a)
with self.assertRaises(Error) as cm:
Expand Down
12 changes: 0 additions & 12 deletions tornado/test/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,6 @@ def exec_test(caller_globals, caller_locals, s):
return local_namespace


def subTest(test, *args, **kwargs):
"""Compatibility shim for unittest.TestCase.subTest.
Usage: ``with tornado.test.util.subTest(self, x=x):``
"""
try:
subTest = test.subTest # py34+
except AttributeError:
subTest = contextlib.contextmanager(lambda *a, **kw: (yield))
return subTest(*args, **kwargs)


@contextlib.contextmanager
def ignore_deprecation():
"""Context manager to ignore deprecation warnings."""
Expand Down

0 comments on commit 77e0a4f

Please sign in to comment.