mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
use assert[Not]In where appropriate
A patch from Dave Malcolm.
This commit is contained in:
parent
a69ba65fdc
commit
577473fe68
75 changed files with 471 additions and 454 deletions
|
@ -35,7 +35,9 @@ class DictTest(unittest.TestCase):
|
|||
d = {'a': 1, 'b': 2}
|
||||
k = d.keys()
|
||||
self.assertTrue('a' in d)
|
||||
self.assertIn('a', d)
|
||||
self.assertTrue('b' in d)
|
||||
self.assertIn('b', d)
|
||||
self.assertRaises(TypeError, d.keys, None)
|
||||
self.assertEqual(repr(dict(a=1).keys()), "dict_keys(['a'])")
|
||||
|
||||
|
@ -60,10 +62,14 @@ class DictTest(unittest.TestCase):
|
|||
d = {}
|
||||
self.assertTrue(not ('a' in d))
|
||||
self.assertTrue('a' not in d)
|
||||
self.assertNotIn('a', d)
|
||||
d = {'a': 1, 'b': 2}
|
||||
self.assertTrue('a' in d)
|
||||
self.assertIn('a', d)
|
||||
self.assertTrue('b' in d)
|
||||
self.assertIn('b', d)
|
||||
self.assertTrue('c' not in d)
|
||||
self.assertNotIn('c', d)
|
||||
|
||||
self.assertRaises(TypeError, d.__contains__)
|
||||
|
||||
|
@ -519,7 +525,9 @@ class DictTest(unittest.TestCase):
|
|||
self.assertEqual(d[1], 2)
|
||||
self.assertEqual(d[3], 4)
|
||||
self.assertTrue(2 not in d)
|
||||
self.assertNotIn(2, d)
|
||||
self.assertTrue(2 not in d.keys())
|
||||
self.assertNotIn(2, d.keys())
|
||||
self.assertEqual(d[2], 42)
|
||||
class E(dict):
|
||||
def __missing__(self, key):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue