summaryrefslogtreecommitdiff
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-01-19 00:09:57 +0000
committerBenjamin Peterson <benjamin@python.org>2010-01-19 00:09:57 +0000
commit3e1025652caea5abed08f93c312829d06cd82475 (patch)
treed611cb1043744ecdbc3cc4705cd725429a3457de /Lib/test/test_weakref.py
parentbcf1d1afae93daaf685a82d4cf51158ebaadad42 (diff)
downloadcpython-3e1025652caea5abed08f93c312829d06cd82475.tar.gz
use assert[Not]In where appropriate
A patch from Dave Malcolm.
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r--Lib/test/test_weakref.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 028b418298..57a098d754 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -193,7 +193,7 @@ class ReferencesTestCase(TestBase):
def __bytes__(self):
return b"bytes"
instance = C()
- self.assertTrue("__bytes__" in dir(weakref.proxy(instance)))
+ self.assertIn("__bytes__", dir(weakref.proxy(instance)))
self.assertEqual(bytes(weakref.proxy(instance)), b"bytes")
def test_proxy_index(self):
@@ -715,8 +715,8 @@ class SubclassableWeakrefTestCase(TestBase):
refs = weakref.getweakrefs(o)
self.assertEqual(len(refs), 3)
self.assertTrue(r2 is refs[0])
- self.assertTrue(r1 in refs[1:])
- self.assertTrue(r3 in refs[1:])
+ self.assertIn(r1, refs[1:])
+ self.assertIn(r3, refs[1:])
def test_subclass_refs_dont_conflate_callbacks(self):
class MyRef(weakref.ref):
@@ -726,8 +726,8 @@ class SubclassableWeakrefTestCase(TestBase):
r2 = MyRef(o, str)
self.assertTrue(r1 is not r2)
refs = weakref.getweakrefs(o)
- self.assertTrue(r1 in refs)
- self.assertTrue(r2 in refs)
+ self.assertIn(r1, refs)
+ self.assertIn(r2, refs)
def test_subclass_refs_with_slots(self):
class MyRef(weakref.ref):
@@ -860,8 +860,8 @@ class MappingTestCase(TestBase):
"deleting the keys did not clear the dictionary")
o = Object(42)
dict[o] = "What is the meaning of the universe?"
- self.assertTrue(o in dict)
- self.assertTrue(34 not in dict)
+ self.assertIn(o, dict)
+ self.assertNotIn(34, dict)
def test_weak_keyed_iters(self):
dict, objects = self.make_weak_keyed_dict()
@@ -873,8 +873,8 @@ class MappingTestCase(TestBase):
objects2 = list(objects)
for wr in refs:
ob = wr()
- self.assertTrue(ob in dict)
- self.assertTrue(ob in dict)
+ self.assertIn(ob, dict)
+ self.assertIn(ob, dict)
self.assertEqual(ob.arg, dict[ob])
objects2.remove(ob)
self.assertEqual(len(objects2), 0)
@@ -884,8 +884,8 @@ class MappingTestCase(TestBase):
self.assertEqual(len(list(dict.keyrefs())), len(objects))
for wr in dict.keyrefs():
ob = wr()
- self.assertTrue(ob in dict)
- self.assertTrue(ob in dict)
+ self.assertIn(ob, dict)
+ self.assertIn(ob, dict)
self.assertEqual(ob.arg, dict[ob])
objects2.remove(ob)
self.assertEqual(len(objects2), 0)
@@ -1091,13 +1091,13 @@ class MappingTestCase(TestBase):
weakdict = klass()
o = weakdict.setdefault(key, value1)
self.assertTrue(o is value1)
- self.assertTrue(key in weakdict)
+ self.assertIn(key, weakdict)
self.assertTrue(weakdict.get(key) is value1)
self.assertTrue(weakdict[key] is value1)
o = weakdict.setdefault(key, value2)
self.assertTrue(o is value1)
- self.assertTrue(key in weakdict)
+ self.assertIn(key, weakdict)
self.assertTrue(weakdict.get(key) is value1)
self.assertTrue(weakdict[key] is value1)