diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-01-19 00:09:57 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-01-19 00:09:57 (GMT) |
commit | 577473fe687b38c8f01b0c372d6d2563680045b3 (patch) | |
tree | ee7dc210c7c5281cf07add09a9cb451758e91716 /Lib/test/test_contains.py | |
parent | a69ba65fdce3be6f55634b47cc56cf1f962f6cbc (diff) | |
download | cpython-577473fe687b38c8f01b0c372d6d2563680045b3.zip cpython-577473fe687b38c8f01b0c372d6d2563680045b3.tar.gz cpython-577473fe687b38c8f01b0c372d6d2563680045b3.tar.bz2 |
use assert[Not]In where appropriate
A patch from Dave Malcolm.
Diffstat (limited to 'Lib/test/test_contains.py')
-rw-r--r-- | Lib/test/test_contains.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/Lib/test/test_contains.py b/Lib/test/test_contains.py index 622dfd4..a667a16 100644 --- a/Lib/test/test_contains.py +++ b/Lib/test/test_contains.py @@ -20,19 +20,19 @@ class TestContains(unittest.TestCase): a = base_set(1) b = myset(1) c = seq(1) - self.assertTrue(1 in b) - self.assertTrue(0 not in b) - self.assertTrue(1 in c) - self.assertTrue(0 not in c) + self.assertIn(1, b) + self.assertNotIn(0, b) + self.assertIn(1, c) + self.assertNotIn(0, c) self.assertRaises(TypeError, lambda: 1 in a) self.assertRaises(TypeError, lambda: 1 not in a) # test char in string - self.assertTrue('c' in 'abc') - self.assertTrue('d' not in 'abc') + self.assertIn('c', 'abc') + self.assertNotIn('d', 'abc') - self.assertTrue('' in '') - self.assertTrue('' in 'abc') + self.assertIn('', '') + self.assertIn('', 'abc') self.assertRaises(TypeError, lambda: None in 'abc') @@ -40,15 +40,15 @@ class TestContains(unittest.TestCase): # a collection of tests on builtin sequence types a = range(10) for i in a: - self.assertTrue(i in a) - self.assertTrue(16 not in a) - self.assertTrue(a not in a) + self.assertIn(i, a) + self.assertNotIn(16, a) + self.assertNotIn(a, a) a = tuple(a) for i in a: - self.assertTrue(i in a) - self.assertTrue(16 not in a) - self.assertTrue(a not in a) + self.assertIn(i, a) + self.assertNotIn(16, a) + self.assertNotIn(a, a) class Deviant1: """Behaves strangely when compared @@ -64,7 +64,7 @@ class TestContains(unittest.TestCase): self.aList.remove(14) return 0 - self.assertTrue(Deviant1() not in Deviant1.aList) + self.assertNotIn(Deviant1(), Deviant1.aList) def test_nonreflexive(self): # containment and equality tests involving elements that are @@ -81,7 +81,7 @@ class TestContains(unittest.TestCase): for constructor in constructors: container = constructor(values) for elem in container: - self.assertTrue(elem in container) + self.assertIn(elem, container) self.assertTrue(container == constructor(values)) self.assertTrue(container == container) |