◐ Shell
clean mode source ↗

Update copy.py from CPython 3.11 by carlosmiei · Pull Request #4674 · RustPython/RustPython

Expand Up @@ -51,6 +51,9 @@ def pickle_C(obj): self.assertRaises(TypeError, copy.copy, x) copyreg.pickle(C, pickle_C, C) y = copy.copy(x) self.assertIsNot(x, y) self.assertEqual(type(y), C) self.assertEqual(y.foo, x.foo)
def test_copy_reduce_ex(self): class C(object): Expand Down Expand Up @@ -315,6 +318,9 @@ def pickle_C(obj): self.assertRaises(TypeError, copy.deepcopy, x) copyreg.pickle(C, pickle_C, C) y = copy.deepcopy(x) self.assertIsNot(x, y) self.assertEqual(type(y), C) self.assertEqual(y.foo, x.foo)
def test_deepcopy_reduce_ex(self): class C(object): Expand Down Expand Up @@ -351,17 +357,15 @@ def __getattribute__(self, name):
# Type-specific _deepcopy_xxx() methods
# TODO: RUSTPYTHON @unittest.expectedFailure def test_deepcopy_atomic(self): class Classic: pass class NewStyle(object): pass def f(): pass tests = [None, 42, 2**100, 3.14, True, False, 1j, "hello", "hello\u1234", f.__code__, tests = [None, ..., NotImplemented, 42, 2**100, 3.14, True, False, 1j, b"bytes", "hello", "hello\u1234", f.__code__, NewStyle, range(10), Classic, max, property()] for x in tests: self.assertIs(copy.deepcopy(x), x) Expand Down Expand Up @@ -684,6 +688,28 @@ def __eq__(self, other): self.assertIsNot(x, y) self.assertIsNot(x["foo"], y["foo"])
def test_reduce_6tuple(self): def state_setter(*args, **kwargs): self.fail("shouldn't call this") class C: def __reduce__(self): return C, (), self.__dict__, None, None, state_setter x = C() with self.assertRaises(TypeError): copy.copy(x) with self.assertRaises(TypeError): copy.deepcopy(x)
def test_reduce_6tuple_none(self): class C: def __reduce__(self): return C, (), self.__dict__, None, None, None x = C() with self.assertRaises(TypeError): copy.copy(x) with self.assertRaises(TypeError): copy.deepcopy(x)
def test_copy_slots(self): class C(object): __slots__ = ["foo"] Expand Down