summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_set.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_set.py')
-rw-r--r--Lib/test/test_set.py118
1 files changed, 59 insertions, 59 deletions
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 222726c..2b43a16 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -65,7 +65,7 @@ class TestJointOps(unittest.TestCase):
self.assertEqual(c in self.s, c in self.d)
self.assertRaises(TypeError, self.s.__contains__, [[]])
s = self.thetype([frozenset(self.letters)])
- self.assert_(self.thetype(self.letters) in s)
+ self.assertTrue(self.thetype(self.letters) in s)
def test_union(self):
u = self.s.union(self.otherword)
@@ -129,7 +129,7 @@ class TestJointOps(unittest.TestCase):
actual = s1.isdisjoint(s2)
expected = f(s1, s2)
self.assertEqual(actual, expected)
- self.assert_(actual is True or actual is False)
+ self.assertTrue(actual is True or actual is False)
def test_and(self):
i = self.s.intersection(self.otherword)
@@ -209,19 +209,19 @@ class TestJointOps(unittest.TestCase):
def test_sub_and_super(self):
p, q, r = map(self.thetype, ['ab', 'abcde', 'def'])
- self.assert_(p < q)
- self.assert_(p <= q)
- self.assert_(q <= q)
- self.assert_(q > p)
- self.assert_(q >= p)
- self.failIf(q < r)
- self.failIf(q <= r)
- self.failIf(q > r)
- self.failIf(q >= r)
- self.assert_(set('a').issubset('abc'))
- self.assert_(set('abc').issuperset('a'))
- self.failIf(set('a').issubset('cbs'))
- self.failIf(set('cbs').issuperset('a'))
+ self.assertTrue(p < q)
+ self.assertTrue(p <= q)
+ self.assertTrue(q <= q)
+ self.assertTrue(q > p)
+ self.assertTrue(q >= p)
+ self.assertFalse(q < r)
+ self.assertFalse(q <= r)
+ self.assertFalse(q > r)
+ self.assertFalse(q >= r)
+ self.assertTrue(set('a').issubset('abc'))
+ self.assertTrue(set('abc').issuperset('a'))
+ self.assertFalse(set('a').issubset('cbs'))
+ self.assertFalse(set('cbs').issuperset('a'))
def test_pickling(self):
for i in range(pickle.HIGHEST_PROTOCOL + 1):
@@ -269,7 +269,7 @@ class TestJointOps(unittest.TestCase):
s=H()
f=set()
f.add(s)
- self.assert_(s in f)
+ self.assertTrue(s in f)
f.remove(s)
f.add(s)
f.discard(s)
@@ -338,7 +338,7 @@ class TestJointOps(unittest.TestCase):
obj.x = iter(container)
del obj, container
gc.collect()
- self.assert_(ref() is None, "Cycle was not collected")
+ self.assertTrue(ref() is None, "Cycle was not collected")
class TestSet(TestJointOps):
thetype = set
@@ -379,7 +379,7 @@ class TestSet(TestJointOps):
def test_add(self):
self.s.add('Q')
- self.assert_('Q' in self.s)
+ self.assertTrue('Q' in self.s)
dup = self.s.copy()
self.s.add('Q')
self.assertEqual(self.s, dup)
@@ -387,13 +387,13 @@ class TestSet(TestJointOps):
def test_remove(self):
self.s.remove('a')
- self.assert_('a' not in self.s)
+ self.assertTrue('a' not in self.s)
self.assertRaises(KeyError, self.s.remove, 'Q')
self.assertRaises(TypeError, self.s.remove, [])
s = self.thetype([frozenset(self.word)])
- self.assert_(self.thetype(self.word) in s)
+ self.assertTrue(self.thetype(self.word) in s)
s.remove(self.thetype(self.word))
- self.assert_(self.thetype(self.word) not in s)
+ self.assertTrue(self.thetype(self.word) not in s)
self.assertRaises(KeyError, self.s.remove, self.thetype(self.word))
def test_remove_keyerror_unpacking(self):
@@ -412,7 +412,7 @@ class TestSet(TestJointOps):
try:
self.s.remove(key)
except KeyError as e:
- self.assert_(e.args[0] is key,
+ self.assertTrue(e.args[0] is key,
"KeyError should be {0}, not {1}".format(key,
e.args[0]))
else:
@@ -420,26 +420,26 @@ class TestSet(TestJointOps):
def test_discard(self):
self.s.discard('a')
- self.assert_('a' not in self.s)
+ self.assertTrue('a' not in self.s)
self.s.discard('Q')
self.assertRaises(TypeError, self.s.discard, [])
s = self.thetype([frozenset(self.word)])
- self.assert_(self.thetype(self.word) in s)
+ self.assertTrue(self.thetype(self.word) in s)
s.discard(self.thetype(self.word))
- self.assert_(self.thetype(self.word) not in s)
+ self.assertTrue(self.thetype(self.word) not in s)
s.discard(self.thetype(self.word))
def test_pop(self):
for i in range(len(self.s)):
elem = self.s.pop()
- self.assert_(elem not in self.s)
+ self.assertTrue(elem not in self.s)
self.assertRaises(KeyError, self.s.pop)
def test_update(self):
retval = self.s.update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
self.assertRaises(PassThru, self.s.update, check_pass_thru())
self.assertRaises(TypeError, self.s.update, [[]])
for p, q in (('cdc', 'abcd'), ('efgfe', 'abcefg'), ('ccb', 'abc'), ('ef', 'abcef')):
@@ -457,16 +457,16 @@ class TestSet(TestJointOps):
def test_ior(self):
self.s |= set(self.otherword)
for c in (self.word + self.otherword):
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
def test_intersection_update(self):
retval = self.s.intersection_update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
if c in self.otherword and c in self.word:
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
self.assertRaises(PassThru, self.s.intersection_update, check_pass_thru())
self.assertRaises(TypeError, self.s.intersection_update, [[]])
for p, q in (('cdc', 'c'), ('efgfe', ''), ('ccb', 'bc'), ('ef', '')):
@@ -484,18 +484,18 @@ class TestSet(TestJointOps):
self.s &= set(self.otherword)
for c in (self.word + self.otherword):
if c in self.otherword and c in self.word:
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
def test_difference_update(self):
retval = self.s.difference_update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
if c in self.word and c not in self.otherword:
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
self.assertRaises(PassThru, self.s.difference_update, check_pass_thru())
self.assertRaises(TypeError, self.s.difference_update, [[]])
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
@@ -521,18 +521,18 @@ class TestSet(TestJointOps):
self.s -= set(self.otherword)
for c in (self.word + self.otherword):
if c in self.word and c not in self.otherword:
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
def test_symmetric_difference_update(self):
retval = self.s.symmetric_difference_update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
if (c in self.word) ^ (c in self.otherword):
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
self.assertRaises(PassThru, self.s.symmetric_difference_update, check_pass_thru())
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
for p, q in (('cdc', 'abd'), ('efgfe', 'abcefg'), ('ccb', 'a'), ('ef', 'abcef')):
@@ -545,9 +545,9 @@ class TestSet(TestJointOps):
self.s ^= set(self.otherword)
for c in (self.word + self.otherword):
if (c in self.word) ^ (c in self.otherword):
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
def test_inplace_on_self(self):
t = self.s.copy()
@@ -590,19 +590,19 @@ class TestSet(TestJointOps):
myobj = TestRichSetCompare()
myset < myobj
- self.assert_(myobj.gt_called)
+ self.assertTrue(myobj.gt_called)
myobj = TestRichSetCompare()
myset > myobj
- self.assert_(myobj.lt_called)
+ self.assertTrue(myobj.lt_called)
myobj = TestRichSetCompare()
myset <= myobj
- self.assert_(myobj.ge_called)
+ self.assertTrue(myobj.ge_called)
myobj = TestRichSetCompare()
myset >= myobj
- self.assert_(myobj.le_called)
+ self.assertTrue(myobj.le_called)
# C API test only available in a debug build
if hasattr(set, "test_c_api"):
@@ -814,7 +814,7 @@ class TestBasicOps(unittest.TestCase):
def test_iteration(self):
for v in self.set:
- self.assert_(v in self.values)
+ self.assertTrue(v in self.values)
setiter = iter(self.set)
# note: __length_hint__ is an internal undocumented API,
# don't rely on it in your own programs
@@ -849,10 +849,10 @@ class TestBasicOpsSingleton(TestBasicOps):
self.repr = "{3}"
def test_in(self):
- self.failUnless(3 in self.set)
+ self.assertTrue(3 in self.set)
def test_not_in(self):
- self.failUnless(2 not in self.set)
+ self.assertTrue(2 not in self.set)
#------------------------------------------------------------------------------
@@ -866,10 +866,10 @@ class TestBasicOpsTuple(TestBasicOps):
self.repr = "{(0, 'zero')}"
def test_in(self):
- self.failUnless((0, "zero") in self.set)
+ self.assertTrue((0, "zero") in self.set)
def test_not_in(self):
- self.failUnless(9 not in self.set)
+ self.assertTrue(9 not in self.set)
#------------------------------------------------------------------------------
@@ -1186,7 +1186,7 @@ class TestMutate(unittest.TestCase):
popped[self.set.pop()] = None
self.assertEqual(len(popped), len(self.values))
for v in self.values:
- self.failUnless(v in popped)
+ self.assertTrue(v in popped)
def test_update_empty_tuple(self):
self.set.update(())
@@ -1455,7 +1455,7 @@ class TestCopying(unittest.TestCase):
set_list = sorted(self.set, key=repr)
self.assertEqual(len(dup_list), len(set_list))
for i in range(len(dup_list)):
- self.failUnless(dup_list[i] is set_list[i])
+ self.assertTrue(dup_list[i] is set_list[i])
def test_deep_copy(self):
dup = copy.deepcopy(self.set)
@@ -1505,13 +1505,13 @@ class TestIdentities(unittest.TestCase):
def test_binopsVsSubsets(self):
a, b = self.a, self.b
- self.assert_(a - b < a)
- self.assert_(b - a < b)
- self.assert_(a & b < a)
- self.assert_(a & b < b)
- self.assert_(a | b > a)
- self.assert_(a | b > b)
- self.assert_(a ^ b < a | b)
+ self.assertTrue(a - b < a)
+ self.assertTrue(b - a < b)
+ self.assertTrue(a & b < a)
+ self.assertTrue(a & b < b)
+ self.assertTrue(a | b > a)
+ self.assertTrue(a | b > b)
+ self.assertTrue(a ^ b < a | b)
def test_commutativity(self):
a, b = self.a, self.b
@@ -1760,7 +1760,7 @@ class TestGraphs(unittest.TestCase):
edge = vertex # Cuboctahedron vertices are edges in Cube
self.assertEqual(len(edge), 2) # Two cube vertices define an edge
for cubevert in edge:
- self.assert_(cubevert in g)
+ self.assertTrue(cubevert in g)
#==============================================================================