mirror of
https://github.com/python/cpython.git
synced 2025-11-01 14:11:41 +00:00
[3.14] gh-71339: Use new assertion methods in tests (GH-129046) (GH-134498)
(cherry picked from commit 2602d8ae98)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
d5f7e80d44
commit
db98e0bb12
117 changed files with 407 additions and 445 deletions
|
|
@ -645,7 +645,7 @@ def do_test(self, args):
|
|||
|
||||
def test_numerictestcase_is_testcase(self):
|
||||
# Ensure that NumericTestCase actually is a TestCase.
|
||||
self.assertTrue(issubclass(NumericTestCase, unittest.TestCase))
|
||||
self.assertIsSubclass(NumericTestCase, unittest.TestCase)
|
||||
|
||||
def test_error_msg_numeric(self):
|
||||
# Test the error message generated for numeric comparisons.
|
||||
|
|
@ -683,32 +683,23 @@ class GlobalsTest(unittest.TestCase):
|
|||
def test_meta(self):
|
||||
# Test for the existence of metadata.
|
||||
for meta in self.expected_metadata:
|
||||
self.assertTrue(hasattr(self.module, meta),
|
||||
"%s not present" % meta)
|
||||
self.assertHasAttr(self.module, meta)
|
||||
|
||||
def test_check_all(self):
|
||||
# Check everything in __all__ exists and is public.
|
||||
module = self.module
|
||||
for name in module.__all__:
|
||||
# No private names in __all__:
|
||||
self.assertFalse(name.startswith("_"),
|
||||
self.assertNotStartsWith(name, "_",
|
||||
'private name "%s" in __all__' % name)
|
||||
# And anything in __all__ must exist:
|
||||
self.assertTrue(hasattr(module, name),
|
||||
'missing name "%s" in __all__' % name)
|
||||
self.assertHasAttr(module, name)
|
||||
|
||||
|
||||
class StatisticsErrorTest(unittest.TestCase):
|
||||
def test_has_exception(self):
|
||||
errmsg = (
|
||||
"Expected StatisticsError to be a ValueError, but got a"
|
||||
" subclass of %r instead."
|
||||
)
|
||||
self.assertTrue(hasattr(statistics, 'StatisticsError'))
|
||||
self.assertTrue(
|
||||
issubclass(statistics.StatisticsError, ValueError),
|
||||
errmsg % statistics.StatisticsError.__base__
|
||||
)
|
||||
self.assertHasAttr(statistics, 'StatisticsError')
|
||||
self.assertIsSubclass(statistics.StatisticsError, ValueError)
|
||||
|
||||
|
||||
# === Tests for private utility functions ===
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue