summaryrefslogtreecommitdiff
path: root/Lib/copy.py
diff options
context:
space:
mode:
authorSandro Tosi <sandro.tosi@gmail.com>2011-08-05 23:05:35 +0200
committerSandro Tosi <sandro.tosi@gmail.com>2011-08-05 23:05:35 +0200
commit4dc9c84ed9ad3a22d37abc06e53c450130bba317 (patch)
tree70dbd523c19a50d2cc24de49e6d65de2af8bc9f2 /Lib/copy.py
parent29f6297605fba9f7313b2aeaf2ddbb06653cfdbb (diff)
downloadcpython-git-4dc9c84ed9ad3a22d37abc06e53c450130bba317.tar.gz
#11572: improvements to copy module tests along with removal of old test suite
Diffstat (limited to 'Lib/copy.py')
-rw-r--r--Lib/copy.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index 497f21fbc7..d96201ea98 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -323,68 +323,3 @@ del types
# Helper for instance creation without calling __init__
class _EmptyClass:
pass
-
-def _test():
- l = [None, 1, 2, 3.14, 'xyzzy', (1, 2), [3.14, 'abc'],
- {'abc': 'ABC'}, (), [], {}]
- l1 = copy(l)
- print(l1==l)
- l1 = map(copy, l)
- print(l1==l)
- l1 = deepcopy(l)
- print(l1==l)
- class C:
- def __init__(self, arg=None):
- self.a = 1
- self.arg = arg
- if __name__ == '__main__':
- import sys
- file = sys.argv[0]
- else:
- file = __file__
- self.fp = open(file)
- self.fp.close()
- def __getstate__(self):
- return {'a': self.a, 'arg': self.arg}
- def __setstate__(self, state):
- for key, value in state.items():
- setattr(self, key, value)
- def __deepcopy__(self, memo=None):
- new = self.__class__(deepcopy(self.arg, memo))
- new.a = self.a
- return new
- c = C('argument sketch')
- l.append(c)
- l2 = copy(l)
- print(l == l2)
- print(l)
- print(l2)
- l2 = deepcopy(l)
- print(l == l2)
- print(l)
- print(l2)
- l.append({l[1]: l, 'xyz': l[2]})
- l3 = copy(l)
- import reprlib
- print(map(reprlib.repr, l))
- print(map(reprlib.repr, l1))
- print(map(reprlib.repr, l2))
- print(map(reprlib.repr, l3))
- l3 = deepcopy(l)
- print(map(reprlib.repr, l))
- print(map(reprlib.repr, l1))
- print(map(reprlib.repr, l2))
- print(map(reprlib.repr, l3))
- class odict(dict):
- def __init__(self, d = {}):
- self.a = 99
- dict.__init__(self, d)
- def __setitem__(self, k, i):
- dict.__setitem__(self, k, i)
- self.a
- o = odict({"A" : "B"})
- x = deepcopy(o)
- print(o, x)
-
-if __name__ == '__main__':
- _test()