summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-03-06 13:03:16 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-03-06 13:03:16 (GMT)
commit9e00088cc5424c1f259f07656206c90f346c41bb (patch)
tree89cb8c12e979588b4201c93e6e5f9dae1c238e72 /Lib
parenta61bfdbecd923a596771a0af5a93cbf17203e23a (diff)
downloadcpython-9e00088cc5424c1f259f07656206c90f346c41bb.zip
cpython-9e00088cc5424c1f259f07656206c90f346c41bb.tar.gz
cpython-9e00088cc5424c1f259f07656206c90f346c41bb.tar.bz2
Issue #26167: Backported copy tests.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_copy.py51
1 files changed, 47 insertions, 4 deletions
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index aefc433..d65f6a2 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -82,7 +82,8 @@ class TestCopy(unittest.TestCase):
pass
def f():
pass
- tests = [None, 42, 2L**100, 3.14, True, False, 1j,
+ tests = [None, Ellipsis,
+ 42, 2L**100, 3.14, True, False, 1j,
"hello", u"hello\u1234", f.func_code,
NewStyle, xrange(10), Classic, max]
for x in tests:
@@ -90,15 +91,57 @@ class TestCopy(unittest.TestCase):
def test_copy_list(self):
x = [1, 2, 3]
- self.assertEqual(copy.copy(x), x)
+ y = copy.copy(x)
+ self.assertEqual(y, x)
+ self.assertIsNot(y, x)
+ x = []
+ y = copy.copy(x)
+ self.assertEqual(y, x)
+ self.assertIsNot(y, x)
def test_copy_tuple(self):
x = (1, 2, 3)
- self.assertEqual(copy.copy(x), x)
+ self.assertIs(copy.copy(x), x)
+ x = ()
+ self.assertIs(copy.copy(x), x)
+ x = (1, 2, 3, [])
+ self.assertIs(copy.copy(x), x)
def test_copy_dict(self):
x = {"foo": 1, "bar": 2}
- self.assertEqual(copy.copy(x), x)
+ y = copy.copy(x)
+ self.assertEqual(y, x)
+ self.assertIsNot(y, x)
+ x = {}
+ y = copy.copy(x)
+ self.assertEqual(y, x)
+ self.assertIsNot(y, x)
+
+ def test_copy_set(self):
+ x = {1, 2, 3}
+ y = copy.copy(x)
+ self.assertEqual(y, x)
+ self.assertIsNot(y, x)
+ x = set()
+ y = copy.copy(x)
+ self.assertEqual(y, x)
+ self.assertIsNot(y, x)
+
+ def test_copy_frozenset(self):
+ x = frozenset({1, 2, 3})
+ self.assertIs(copy.copy(x), x)
+ x = frozenset()
+ self.assertIs(copy.copy(x), x)
+
+ def test_copy_bytearray(self):
+ x = bytearray(b'abc')
+ y = copy.copy(x)
+ self.assertEqual(y, x)
+ self.assertIsNot(y, x)
+ x = bytearray()
+ y = copy.copy(x)
+ self.assertEqual(y, x)
+ self.assertIsNot(y, x)
def test_copy_inst_vanilla(self):
class C: