mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #19594: Use specific asserts in unittest tests.
This commit is contained in:
commit
bc39869095
7 changed files with 28 additions and 28 deletions
|
@ -407,7 +407,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
|
|||
def test(self):
|
||||
pass
|
||||
|
||||
self.assertTrue(Foo('test').failureException is AssertionError)
|
||||
self.assertIs(Foo('test').failureException, AssertionError)
|
||||
|
||||
# "This class attribute gives the exception raised by the test() method.
|
||||
# If a test framework needs to use a specialized exception, possibly to
|
||||
|
@ -425,7 +425,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
|
|||
|
||||
failureException = RuntimeError
|
||||
|
||||
self.assertTrue(Foo('test').failureException is RuntimeError)
|
||||
self.assertIs(Foo('test').failureException, RuntimeError)
|
||||
|
||||
|
||||
Foo('test').run(result)
|
||||
|
@ -448,7 +448,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
|
|||
|
||||
failureException = RuntimeError
|
||||
|
||||
self.assertTrue(Foo('test').failureException is RuntimeError)
|
||||
self.assertIs(Foo('test').failureException, RuntimeError)
|
||||
|
||||
|
||||
Foo('test').run(result)
|
||||
|
@ -760,7 +760,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
|
|||
msg = e.args[0]
|
||||
else:
|
||||
self.fail('assertSequenceEqual did not fail.')
|
||||
self.assertTrue(len(msg) < len(diff))
|
||||
self.assertLess(len(msg), len(diff))
|
||||
self.assertIn(omitted, msg)
|
||||
|
||||
self.maxDiff = len(diff) * 2
|
||||
|
@ -770,7 +770,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
|
|||
msg = e.args[0]
|
||||
else:
|
||||
self.fail('assertSequenceEqual did not fail.')
|
||||
self.assertTrue(len(msg) > len(diff))
|
||||
self.assertGreater(len(msg), len(diff))
|
||||
self.assertNotIn(omitted, msg)
|
||||
|
||||
self.maxDiff = None
|
||||
|
@ -780,7 +780,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
|
|||
msg = e.args[0]
|
||||
else:
|
||||
self.fail('assertSequenceEqual did not fail.')
|
||||
self.assertTrue(len(msg) > len(diff))
|
||||
self.assertGreater(len(msg), len(diff))
|
||||
self.assertNotIn(omitted, msg)
|
||||
|
||||
def testTruncateMessage(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue