Kaydet (Commit) 6cca754c authored tarafından Tim Peters's avatar Tim Peters

TestOnlySetsInBinaryOps: Simplified the non-inplace tests by using

assertRaises.  Fixed a repeated subtle bug in the inplace tests by
removing the possibilty that a self.fail() call could raise a
TypeError that the test catches by mistake.
üst b7bfe4be
......@@ -506,78 +506,50 @@ class TestOnlySetsInBinaryOps(unittest.TestCase):
def test_union_update(self):
try:
self.set |= self.other
self.fail("expected TypeError")
except TypeError:
pass
else:
self.fail("expected TypeError")
def test_union(self):
try:
self.other | self.set
self.fail("expected TypeError")
except TypeError:
pass
try:
self.set | self.other
self.fail("expected TypeError")
except TypeError:
pass
self.assertRaises(TypeError, lambda: self.set | self.other)
self.assertRaises(TypeError, lambda: self.other | self.set)
def test_intersection_update(self):
try:
self.set &= self.other
self.fail("expected TypeError")
except TypeError:
pass
else:
self.fail("expected TypeError")
def test_intersection(self):
try:
self.other & self.set
self.fail("expected TypeError")
except TypeError:
pass
try:
self.set & self.other
self.fail("expected TypeError")
except TypeError:
pass
self.assertRaises(TypeError, lambda: self.set & self.other)
self.assertRaises(TypeError, lambda: self.other & self.set)
def test_sym_difference_update(self):
try:
self.set ^= self.other
self.fail("expected TypeError")
except TypeError:
pass
else:
self.fail("expected TypeError")
def test_sym_difference(self):
try:
self.other ^ self.set
self.fail("expected TypeError")
except TypeError:
pass
try:
self.set ^ self.other
self.fail("expected TypeError")
except TypeError:
pass
self.assertRaises(TypeError, lambda: self.set ^ self.other)
self.assertRaises(TypeError, lambda: self.other ^ self.set)
def test_difference_update(self):
try:
self.set -= self.other
self.fail("expected TypeError")
except TypeError:
pass
else:
self.fail("expected TypeError")
def test_difference(self):
try:
self.other - self.set
self.fail("expected TypeError")
except TypeError:
pass
try:
self.set - self.other
self.fail("expected TypeError")
except TypeError:
pass
self.assertRaises(TypeError, lambda: self.set - self.other)
self.assertRaises(TypeError, lambda: self.other - self.set)
#------------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment