summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_copy.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2006-02-25 22:38:04 (GMT)
committerGuido van Rossum <guido@python.org>2006-02-25 22:38:04 (GMT)
commit1968ad32cd7f46d9bb64826672ef68cdaee35288 (patch)
treec46db5a446d9de18fb8436408ec29d2111a2f5ad /Lib/test/test_copy.py
parentab51f5f24d6f6edef5e8fac5e31b2e4ac0cbdbac (diff)
downloadcpython-1968ad32cd7f46d9bb64826672ef68cdaee35288.zip
cpython-1968ad32cd7f46d9bb64826672ef68cdaee35288.tar.gz
cpython-1968ad32cd7f46d9bb64826672ef68cdaee35288.tar.bz2
- Patch 1433928:
- The copy module now "copies" function objects (as atomic objects). - dict.__getitem__ now looks for a __missing__ hook before raising KeyError. - Added a new type, defaultdict, to the collections module. This uses the new __missing__ hook behavior added to dict (see above).
Diffstat (limited to 'Lib/test/test_copy.py')
-rw-r--r--Lib/test/test_copy.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index bd5a3e1..ff4c987 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -568,6 +568,22 @@ class TestCopy(unittest.TestCase):
raise ValueError, "ain't got no stickin' state"
self.assertRaises(ValueError, copy.copy, EvilState())
+ def test_copy_function(self):
+ self.assertEqual(copy.copy(global_foo), global_foo)
+ def foo(x, y): return x+y
+ self.assertEqual(copy.copy(foo), foo)
+ bar = lambda: None
+ self.assertEqual(copy.copy(bar), bar)
+
+ def test_deepcopy_function(self):
+ self.assertEqual(copy.deepcopy(global_foo), global_foo)
+ def foo(x, y): return x+y
+ self.assertEqual(copy.deepcopy(foo), foo)
+ bar = lambda: None
+ self.assertEqual(copy.deepcopy(bar), bar)
+
+def global_foo(x, y): return x+y
+
def test_main():
test_support.run_unittest(TestCopy)