-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
After working on #100817 I've noticed that there are multiple things that can be improved in terms of copy
module tests:
- First of all, I had submitted some broken code in gh-100817: Speed up
copy.deepcopy
calls onslice
objects #100818 but, our test cases were not able to detect it. Solution: add a new test case intest_slice.py
withcopy
anddeepcopy
calls. I think it should be intest_slice
and not intest_copy
, because there's nothing special about it:copy
does not change its behaviour or special case it. - This test ensures that after modifing
copyreg
we can now copy an object, but does not assert the result:Lines 42 to 55 in e47b139
def test_copy_registry(self): class C(object): def __new__(cls, foo): obj = object.__new__(cls) obj.foo = foo return obj def pickle_C(obj): return (C, (obj.foo,)) x = C(42) self.assertRaises(TypeError, copy.copy, x) copyreg.pickle(C, pickle_C, C) y = copy.copy(x) def test_copy_reduce_ex(self): Lines 302 to 315 in e47b139
def test_deepcopy_registry(self): class C(object): def __new__(cls, foo): obj = object.__new__(cls) obj.foo = foo return obj def pickle_C(obj): return (C, (obj.foo,)) x = C(42) self.assertRaises(TypeError, copy.deepcopy, x) copyreg.pickle(C, pickle_C, C) y = copy.deepcopy(x) def test_deepcopy_reduce_ex(self): test_deepcopy_atomic
misses several important types:bytes
,types.EllipsisType
,NotImplementedType
.Lines 350 to 359 in e47b139
def test_deepcopy_atomic(self): class NewStyle: pass def f(): pass tests = [None, 42, 2**100, 3.14, True, False, 1j, "hello", "hello\u1234", f.__code__, NewStyle, range(10), max, property()] for x in tests: self.assertIs(copy.deepcopy(x), x)
PR is incoming.
Linked PRs
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error