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_descr.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_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 8e45bcf..57b69e6 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -500,7 +500,7 @@ class ClassPropertiesAndMethods(unittest.TestCase): return 42 self.assertEqual(C.name, 'C') self.assertEqual(C.bases, ()) - self.assertTrue('spam' in C.dict) + self.assertIn('spam', C.dict) c = C() self.assertEqual(c.spam(), 42) @@ -1651,9 +1651,9 @@ order (MRO) for bases """ # depending on whether this test is run standalone or from a framework. self.assertTrue(str(c1).find('C object at ') >= 0) self.assertEqual(str(c1), repr(c1)) - self.assertTrue(-1 not in c1) + self.assertNotIn(-1, c1) for i in range(10): - self.assertTrue(i in c1) + self.assertIn(i, c1) self.assertFalse(10 in c1) # Test the default behavior for dynamic classes class D(object): @@ -1674,9 +1674,9 @@ order (MRO) for bases """ # depending on whether this test is run standalone or from a framework. self.assertTrue(str(d1).find('D object at ') >= 0) self.assertEqual(str(d1), repr(d1)) - self.assertTrue(-1 not in d1) + self.assertNotIn(-1, d1) for i in range(10): - self.assertTrue(i in d1) + self.assertIn(i, d1) self.assertFalse(10 in d1) # Test overridden behavior class Proxy(object): @@ -1723,7 +1723,7 @@ order (MRO) for bases """ p10 = Proxy(range(10)) self.assertFalse(-1 in p10) for i in range(10): - self.assertTrue(i in p10) + self.assertIn(i, p10) self.assertFalse(10 in p10) def test_weakrefs(self): @@ -1784,10 +1784,10 @@ order (MRO) for bases """ self.assertTrue(isinstance(raw, property)) attrs = dir(raw) - self.assertTrue("__doc__" in attrs) - self.assertTrue("fget" in attrs) - self.assertTrue("fset" in attrs) - self.assertTrue("fdel" in attrs) + self.assertIn("__doc__", attrs) + self.assertIn("fget", attrs) + self.assertIn("fset", attrs) + self.assertIn("fdel", attrs) self.assertEqual(raw.__doc__, "I'm the x property.") self.assertTrue(raw.fget is C.__dict__['getx']) @@ -2012,12 +2012,12 @@ order (MRO) for bases """ c = C() self.assertEqual(interesting(dir(c)), cstuff) - ## self.assertTrue('__self__' in dir(C.Cmethod)) + ## self.assertIn('__self__', dir(C.Cmethod)) c.cdata = 2 c.cmethod = lambda self: 0 self.assertEqual(interesting(dir(c)), cstuff + ['cdata', 'cmethod']) - ## self.assertTrue('__self__' in dir(c.Cmethod)) + ## self.assertIn('__self__', dir(c.Cmethod)) class A(C): Adata = 1 @@ -2025,13 +2025,13 @@ order (MRO) for bases """ astuff = ['Adata', 'Amethod'] + cstuff self.assertEqual(interesting(dir(A)), astuff) - ## self.assertTrue('__self__' in dir(A.Amethod)) + ## self.assertIn('__self__', dir(A.Amethod)) a = A() self.assertEqual(interesting(dir(a)), astuff) a.adata = 42 a.amethod = lambda self: 3 self.assertEqual(interesting(dir(a)), astuff + ['adata', 'amethod']) - ## self.assertTrue('__self__' in dir(a.Amethod)) + ## self.assertIn('__self__', dir(a.Amethod)) # Try a module subclass. import sys @@ -2583,7 +2583,7 @@ order (MRO) for bases """ self.assertEqual(d[cistr('one')], 1) self.assertEqual(d[cistr('tWo')], 2) self.assertEqual(d[cistr('THrEE')], 3) - self.assertTrue(cistr('ONe') in d) + self.assertIn(cistr('ONe'), d) self.assertEqual(d.get(cistr('thrEE')), 3) def test_classic_comparisons(self): |