mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
convert usage of fail* to assert*
This commit is contained in:
parent
be96cf608f
commit
5c8da86f3a
268 changed files with 5017 additions and 5017 deletions
|
@ -13,8 +13,8 @@ class TestCopy(unittest.TestCase):
|
|||
# Attempt full line coverage of copy.py from top to bottom
|
||||
|
||||
def test_exceptions(self):
|
||||
self.assert_(copy.Error is copy.error)
|
||||
self.assert_(issubclass(copy.Error, Exception))
|
||||
self.assertTrue(copy.Error is copy.error)
|
||||
self.assertTrue(issubclass(copy.Error, Exception))
|
||||
|
||||
# The copy() method
|
||||
|
||||
|
@ -55,7 +55,7 @@ class TestCopy(unittest.TestCase):
|
|||
raise test_support.TestFailed, "shouldn't call this"
|
||||
x = C()
|
||||
y = copy.copy(x)
|
||||
self.assert_(y is x)
|
||||
self.assertTrue(y is x)
|
||||
|
||||
def test_copy_reduce(self):
|
||||
class C(object):
|
||||
|
@ -63,7 +63,7 @@ class TestCopy(unittest.TestCase):
|
|||
return ""
|
||||
x = C()
|
||||
y = copy.copy(x)
|
||||
self.assert_(y is x)
|
||||
self.assertTrue(y is x)
|
||||
|
||||
def test_copy_cant(self):
|
||||
class C(object):
|
||||
|
@ -87,7 +87,7 @@ class TestCopy(unittest.TestCase):
|
|||
"hello", u"hello\u1234", f.func_code,
|
||||
NewStyle, xrange(10), Classic, max]
|
||||
for x in tests:
|
||||
self.assert_(copy.copy(x) is x, repr(x))
|
||||
self.assertTrue(copy.copy(x) is x, repr(x))
|
||||
|
||||
def test_copy_list(self):
|
||||
x = [1, 2, 3]
|
||||
|
@ -181,9 +181,9 @@ class TestCopy(unittest.TestCase):
|
|||
x = [x, x]
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y[0] is not x[0])
|
||||
self.assert_(y[0] is y[1])
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y[0] is not x[0])
|
||||
self.assertTrue(y[0] is y[1])
|
||||
|
||||
def test_deepcopy_issubclass(self):
|
||||
# XXX Note: there's no way to test the TypeError coming out of
|
||||
|
@ -228,7 +228,7 @@ class TestCopy(unittest.TestCase):
|
|||
raise test_support.TestFailed, "shouldn't call this"
|
||||
x = C()
|
||||
y = copy.deepcopy(x)
|
||||
self.assert_(y is x)
|
||||
self.assertTrue(y is x)
|
||||
|
||||
def test_deepcopy_reduce(self):
|
||||
class C(object):
|
||||
|
@ -236,7 +236,7 @@ class TestCopy(unittest.TestCase):
|
|||
return ""
|
||||
x = C()
|
||||
y = copy.deepcopy(x)
|
||||
self.assert_(y is x)
|
||||
self.assertTrue(y is x)
|
||||
|
||||
def test_deepcopy_cant(self):
|
||||
class C(object):
|
||||
|
@ -260,61 +260,61 @@ class TestCopy(unittest.TestCase):
|
|||
"hello", u"hello\u1234", f.func_code,
|
||||
NewStyle, xrange(10), Classic, max]
|
||||
for x in tests:
|
||||
self.assert_(copy.deepcopy(x) is x, repr(x))
|
||||
self.assertTrue(copy.deepcopy(x) is x, repr(x))
|
||||
|
||||
def test_deepcopy_list(self):
|
||||
x = [[1, 2], 3]
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(x is not y)
|
||||
self.assert_(x[0] is not y[0])
|
||||
self.assertTrue(x is not y)
|
||||
self.assertTrue(x[0] is not y[0])
|
||||
|
||||
def test_deepcopy_reflexive_list(self):
|
||||
x = []
|
||||
x.append(x)
|
||||
y = copy.deepcopy(x)
|
||||
self.assertRaises(RuntimeError, cmp, y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y[0] is y)
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y[0] is y)
|
||||
self.assertEqual(len(y), 1)
|
||||
|
||||
def test_deepcopy_tuple(self):
|
||||
x = ([1, 2], 3)
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(x is not y)
|
||||
self.assert_(x[0] is not y[0])
|
||||
self.assertTrue(x is not y)
|
||||
self.assertTrue(x[0] is not y[0])
|
||||
|
||||
def test_deepcopy_reflexive_tuple(self):
|
||||
x = ([],)
|
||||
x[0].append(x)
|
||||
y = copy.deepcopy(x)
|
||||
self.assertRaises(RuntimeError, cmp, y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y[0] is not x[0])
|
||||
self.assert_(y[0][0] is y)
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y[0] is not x[0])
|
||||
self.assertTrue(y[0][0] is y)
|
||||
|
||||
def test_deepcopy_dict(self):
|
||||
x = {"foo": [1, 2], "bar": 3}
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(x is not y)
|
||||
self.assert_(x["foo"] is not y["foo"])
|
||||
self.assertTrue(x is not y)
|
||||
self.assertTrue(x["foo"] is not y["foo"])
|
||||
|
||||
def test_deepcopy_reflexive_dict(self):
|
||||
x = {}
|
||||
x['foo'] = x
|
||||
y = copy.deepcopy(x)
|
||||
self.assertRaises(RuntimeError, cmp, y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y['foo'] is y)
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y['foo'] is y)
|
||||
self.assertEqual(len(y), 1)
|
||||
|
||||
def test_deepcopy_keepalive(self):
|
||||
memo = {}
|
||||
x = 42
|
||||
y = copy.deepcopy(x, memo)
|
||||
self.assert_(memo[id(x)] is x)
|
||||
self.assertTrue(memo[id(x)] is x)
|
||||
|
||||
def test_deepcopy_inst_vanilla(self):
|
||||
class C:
|
||||
|
@ -325,7 +325,7 @@ class TestCopy(unittest.TestCase):
|
|||
x = C([42])
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(y.foo is not x.foo)
|
||||
self.assertTrue(y.foo is not x.foo)
|
||||
|
||||
def test_deepcopy_inst_deepcopy(self):
|
||||
class C:
|
||||
|
@ -338,8 +338,8 @@ class TestCopy(unittest.TestCase):
|
|||
x = C([42])
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y.foo is not x.foo)
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y.foo is not x.foo)
|
||||
|
||||
def test_deepcopy_inst_getinitargs(self):
|
||||
class C:
|
||||
|
@ -352,8 +352,8 @@ class TestCopy(unittest.TestCase):
|
|||
x = C([42])
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y.foo is not x.foo)
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y.foo is not x.foo)
|
||||
|
||||
def test_deepcopy_inst_getstate(self):
|
||||
class C:
|
||||
|
@ -366,8 +366,8 @@ class TestCopy(unittest.TestCase):
|
|||
x = C([42])
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y.foo is not x.foo)
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y.foo is not x.foo)
|
||||
|
||||
def test_deepcopy_inst_setstate(self):
|
||||
class C:
|
||||
|
@ -380,8 +380,8 @@ class TestCopy(unittest.TestCase):
|
|||
x = C([42])
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y.foo is not x.foo)
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y.foo is not x.foo)
|
||||
|
||||
def test_deepcopy_inst_getstate_setstate(self):
|
||||
class C:
|
||||
|
@ -396,8 +396,8 @@ class TestCopy(unittest.TestCase):
|
|||
x = C([42])
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y.foo is not x.foo)
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y.foo is not x.foo)
|
||||
|
||||
def test_deepcopy_reflexive_inst(self):
|
||||
class C:
|
||||
|
@ -405,8 +405,8 @@ class TestCopy(unittest.TestCase):
|
|||
x = C()
|
||||
x.foo = x
|
||||
y = copy.deepcopy(x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y.foo is y)
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y.foo is y)
|
||||
|
||||
# _reconstruct()
|
||||
|
||||
|
@ -416,9 +416,9 @@ class TestCopy(unittest.TestCase):
|
|||
return ""
|
||||
x = C()
|
||||
y = copy.copy(x)
|
||||
self.assert_(y is x)
|
||||
self.assertTrue(y is x)
|
||||
y = copy.deepcopy(x)
|
||||
self.assert_(y is x)
|
||||
self.assertTrue(y is x)
|
||||
|
||||
def test_reconstruct_nostate(self):
|
||||
class C(object):
|
||||
|
@ -427,9 +427,9 @@ class TestCopy(unittest.TestCase):
|
|||
x = C()
|
||||
x.foo = 42
|
||||
y = copy.copy(x)
|
||||
self.assert_(y.__class__ is x.__class__)
|
||||
self.assertTrue(y.__class__ is x.__class__)
|
||||
y = copy.deepcopy(x)
|
||||
self.assert_(y.__class__ is x.__class__)
|
||||
self.assertTrue(y.__class__ is x.__class__)
|
||||
|
||||
def test_reconstruct_state(self):
|
||||
class C(object):
|
||||
|
@ -444,7 +444,7 @@ class TestCopy(unittest.TestCase):
|
|||
self.assertEqual(y, x)
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(y.foo is not x.foo)
|
||||
self.assertTrue(y.foo is not x.foo)
|
||||
|
||||
def test_reconstruct_state_setstate(self):
|
||||
class C(object):
|
||||
|
@ -461,7 +461,7 @@ class TestCopy(unittest.TestCase):
|
|||
self.assertEqual(y, x)
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assert_(y.foo is not x.foo)
|
||||
self.assertTrue(y.foo is not x.foo)
|
||||
|
||||
def test_reconstruct_reflexive(self):
|
||||
class C(object):
|
||||
|
@ -469,8 +469,8 @@ class TestCopy(unittest.TestCase):
|
|||
x = C()
|
||||
x.foo = x
|
||||
y = copy.deepcopy(x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y.foo is y)
|
||||
self.assertTrue(y is not x)
|
||||
self.assertTrue(y.foo is y)
|
||||
|
||||
# Additions for Python 2.3 and pickle protocol 2
|
||||
|
||||
|
@ -485,12 +485,12 @@ class TestCopy(unittest.TestCase):
|
|||
x = C([[1, 2], 3])
|
||||
y = copy.copy(x)
|
||||
self.assertEqual(x, y)
|
||||
self.assert_(x is not y)
|
||||
self.assert_(x[0] is y[0])
|
||||
self.assertTrue(x is not y)
|
||||
self.assertTrue(x[0] is y[0])
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(x, y)
|
||||
self.assert_(x is not y)
|
||||
self.assert_(x[0] is not y[0])
|
||||
self.assertTrue(x is not y)
|
||||
self.assertTrue(x[0] is not y[0])
|
||||
|
||||
def test_reduce_5tuple(self):
|
||||
class C(dict):
|
||||
|
@ -503,12 +503,12 @@ class TestCopy(unittest.TestCase):
|
|||
x = C([("foo", [1, 2]), ("bar", 3)])
|
||||
y = copy.copy(x)
|
||||
self.assertEqual(x, y)
|
||||
self.assert_(x is not y)
|
||||
self.assert_(x["foo"] is y["foo"])
|
||||
self.assertTrue(x is not y)
|
||||
self.assertTrue(x["foo"] is y["foo"])
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(x, y)
|
||||
self.assert_(x is not y)
|
||||
self.assert_(x["foo"] is not y["foo"])
|
||||
self.assertTrue(x is not y)
|
||||
self.assertTrue(x["foo"] is not y["foo"])
|
||||
|
||||
def test_copy_slots(self):
|
||||
class C(object):
|
||||
|
@ -516,7 +516,7 @@ class TestCopy(unittest.TestCase):
|
|||
x = C()
|
||||
x.foo = [42]
|
||||
y = copy.copy(x)
|
||||
self.assert_(x.foo is y.foo)
|
||||
self.assertTrue(x.foo is y.foo)
|
||||
|
||||
def test_deepcopy_slots(self):
|
||||
class C(object):
|
||||
|
@ -525,7 +525,7 @@ class TestCopy(unittest.TestCase):
|
|||
x.foo = [42]
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(x.foo, y.foo)
|
||||
self.assert_(x.foo is not y.foo)
|
||||
self.assertTrue(x.foo is not y.foo)
|
||||
|
||||
def test_copy_list_subclass(self):
|
||||
class C(list):
|
||||
|
@ -535,8 +535,8 @@ class TestCopy(unittest.TestCase):
|
|||
y = copy.copy(x)
|
||||
self.assertEqual(list(x), list(y))
|
||||
self.assertEqual(x.foo, y.foo)
|
||||
self.assert_(x[0] is y[0])
|
||||
self.assert_(x.foo is y.foo)
|
||||
self.assertTrue(x[0] is y[0])
|
||||
self.assertTrue(x.foo is y.foo)
|
||||
|
||||
def test_deepcopy_list_subclass(self):
|
||||
class C(list):
|
||||
|
@ -546,8 +546,8 @@ class TestCopy(unittest.TestCase):
|
|||
y = copy.deepcopy(x)
|
||||
self.assertEqual(list(x), list(y))
|
||||
self.assertEqual(x.foo, y.foo)
|
||||
self.assert_(x[0] is not y[0])
|
||||
self.assert_(x.foo is not y.foo)
|
||||
self.assertTrue(x[0] is not y[0])
|
||||
self.assertTrue(x.foo is not y.foo)
|
||||
|
||||
def test_copy_tuple_subclass(self):
|
||||
class C(tuple):
|
||||
|
@ -564,8 +564,8 @@ class TestCopy(unittest.TestCase):
|
|||
self.assertEqual(tuple(x), ([1, 2], 3))
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(tuple(y), ([1, 2], 3))
|
||||
self.assert_(x is not y)
|
||||
self.assert_(x[0] is not y[0])
|
||||
self.assertTrue(x is not y)
|
||||
self.assertTrue(x[0] is not y[0])
|
||||
|
||||
def test_getstate_exc(self):
|
||||
class EvilState(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue