mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
b7bfe4bea4
commit
6cca754c20
|
@ -506,78 +506,50 @@ class TestOnlySetsInBinaryOps(unittest.TestCase):
|
||||||
def test_union_update(self):
|
def test_union_update(self):
|
||||||
try:
|
try:
|
||||||
self.set |= self.other
|
self.set |= self.other
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
self.fail("expected TypeError")
|
||||||
|
|
||||||
def test_union(self):
|
def test_union(self):
|
||||||
try:
|
self.assertRaises(TypeError, lambda: self.set | self.other)
|
||||||
self.other | self.set
|
self.assertRaises(TypeError, lambda: self.other | self.set)
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
self.set | self.other
|
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def test_intersection_update(self):
|
def test_intersection_update(self):
|
||||||
try:
|
try:
|
||||||
self.set &= self.other
|
self.set &= self.other
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
self.fail("expected TypeError")
|
||||||
|
|
||||||
def test_intersection(self):
|
def test_intersection(self):
|
||||||
try:
|
self.assertRaises(TypeError, lambda: self.set & self.other)
|
||||||
self.other & self.set
|
self.assertRaises(TypeError, lambda: self.other & self.set)
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
self.set & self.other
|
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def test_sym_difference_update(self):
|
def test_sym_difference_update(self):
|
||||||
try:
|
try:
|
||||||
self.set ^= self.other
|
self.set ^= self.other
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
self.fail("expected TypeError")
|
||||||
|
|
||||||
def test_sym_difference(self):
|
def test_sym_difference(self):
|
||||||
try:
|
self.assertRaises(TypeError, lambda: self.set ^ self.other)
|
||||||
self.other ^ self.set
|
self.assertRaises(TypeError, lambda: self.other ^ self.set)
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
self.set ^ self.other
|
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def test_difference_update(self):
|
def test_difference_update(self):
|
||||||
try:
|
try:
|
||||||
self.set -= self.other
|
self.set -= self.other
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
self.fail("expected TypeError")
|
||||||
|
|
||||||
def test_difference(self):
|
def test_difference(self):
|
||||||
try:
|
self.assertRaises(TypeError, lambda: self.set - self.other)
|
||||||
self.other - self.set
|
self.assertRaises(TypeError, lambda: self.other - self.set)
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
self.set - self.other
|
|
||||||
self.fail("expected TypeError")
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue