summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unittest/test_program.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2025-01-14 08:02:38 (GMT)
committerGitHub <noreply@github.com>2025-01-14 08:02:38 (GMT)
commit06cad77a5b345adde88609be9c3c470c5cd9f417 (patch)
tree3c66069a2a22b4bffe221c3db5da638faad45ee9 /Lib/test/test_unittest/test_program.py
parent41f73501eca2ff8b42fa4811d918a81c052a758b (diff)
downloadcpython-06cad77a5b345adde88609be9c3c470c5cd9f417.zip
cpython-06cad77a5b345adde88609be9c3c470c5cd9f417.tar.gz
cpython-06cad77a5b345adde88609be9c3c470c5cd9f417.tar.bz2
gh-71339: Add additional assertion methods for unittest (GH-128707)
Add the following methods: * assertHasAttr() and assertNotHasAttr() * assertIsSubclass() and assertNotIsSubclass() * assertStartsWith() and assertNotStartsWith() * assertEndsWith() and assertNotEndsWith() Also improve error messages for assertIsInstance() and assertNotIsInstance().
Diffstat (limited to 'Lib/test/test_unittest/test_program.py')
-rw-r--r--Lib/test/test_unittest/test_program.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/test/test_unittest/test_program.py b/Lib/test/test_unittest/test_program.py
index 0b46f33..58d0cef 100644
--- a/Lib/test/test_unittest/test_program.py
+++ b/Lib/test/test_unittest/test_program.py
@@ -128,14 +128,14 @@ class Test_TestProgram(unittest.TestCase):
argv=["foobar"],
testRunner=unittest.TextTestRunner(stream=stream),
testLoader=self.TestLoader(self.FooBar))
- self.assertTrue(hasattr(program, 'result'))
+ self.assertHasAttr(program, 'result')
out = stream.getvalue()
self.assertIn('\nFAIL: testFail ', out)
self.assertIn('\nERROR: testError ', out)
self.assertIn('\nUNEXPECTED SUCCESS: testUnexpectedSuccess ', out)
expected = ('\n\nFAILED (failures=1, errors=1, skipped=1, '
'expected failures=1, unexpected successes=1)\n')
- self.assertTrue(out.endswith(expected))
+ self.assertEndsWith(out, expected)
@force_not_colorized
def test_Exit(self):
@@ -153,7 +153,7 @@ class Test_TestProgram(unittest.TestCase):
self.assertIn('\nUNEXPECTED SUCCESS: testUnexpectedSuccess ', out)
expected = ('\n\nFAILED (failures=1, errors=1, skipped=1, '
'expected failures=1, unexpected successes=1)\n')
- self.assertTrue(out.endswith(expected))
+ self.assertEndsWith(out, expected)
@force_not_colorized
def test_ExitAsDefault(self):
@@ -169,7 +169,7 @@ class Test_TestProgram(unittest.TestCase):
self.assertIn('\nUNEXPECTED SUCCESS: testUnexpectedSuccess ', out)
expected = ('\n\nFAILED (failures=1, errors=1, skipped=1, '
'expected failures=1, unexpected successes=1)\n')
- self.assertTrue(out.endswith(expected))
+ self.assertEndsWith(out, expected)
@force_not_colorized
def test_ExitSkippedSuite(self):
@@ -182,7 +182,7 @@ class Test_TestProgram(unittest.TestCase):
self.assertEqual(cm.exception.code, 0)
out = stream.getvalue()
expected = '\n\nOK (skipped=1)\n'
- self.assertTrue(out.endswith(expected))
+ self.assertEndsWith(out, expected)
@force_not_colorized
def test_ExitEmptySuite(self):