summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_statistics.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2025-05-22 10:42:50 (GMT)
committerGitHub <noreply@github.com>2025-05-22 10:42:50 (GMT)
commitdb98e0bb127c469842dc119d23e5daacd23862cc (patch)
tree5628e04625c93f2e5bde25aa29dedb3c154a0dec /Lib/test/test_statistics.py
parentd5f7e80d4407655919b32bbd5746b23af174bc5b (diff)
downloadcpython-db98e0bb127c469842dc119d23e5daacd23862cc.zip
cpython-db98e0bb127c469842dc119d23e5daacd23862cc.tar.gz
cpython-db98e0bb127c469842dc119d23e5daacd23862cc.tar.bz2
[3.14] gh-71339: Use new assertion methods in tests (GH-129046) (GH-134498)
(cherry picked from commit 2602d8ae981c4bae1cada2c174b367d97f712efb) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_statistics.py')
-rw-r--r--Lib/test/test_statistics.py21
1 files changed, 6 insertions, 15 deletions
diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py
index c69baa4..5980f93 100644
--- a/Lib/test/test_statistics.py
+++ b/Lib/test/test_statistics.py
@@ -645,7 +645,7 @@ class TestNumericTestCase(unittest.TestCase):
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 ===