Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(34)

Side by Side Diff: Lib/test/test_copy.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_concurrent_futures.py ('k') | Lib/test/test_cprofile.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Unit tests for the copy module.""" 1 """Unit tests for the copy module."""
2 2
3 import copy 3 import copy
4 import copyreg 4 import copyreg
5 import weakref 5 import weakref
6 from operator import le, lt, ge, gt, eq, ne 6 from operator import le, lt, ge, gt, eq, ne
7 7
8 import unittest 8 import unittest
9 from test import support 9 from test import support
10 10
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 for op in order_comparisons: 314 for op in order_comparisons:
315 self.assertRaises(TypeError, op, y, x) 315 self.assertRaises(TypeError, op, y, x)
316 for op in equality_comparisons: 316 for op in equality_comparisons:
317 self.assertRaises(RuntimeError, op, y, x) 317 self.assertRaises(RuntimeError, op, y, x)
318 self.assertTrue(y is not x) 318 self.assertTrue(y is not x)
319 self.assertTrue(y['foo'] is y) 319 self.assertTrue(y['foo'] is y)
320 self.assertEqual(len(y), 1) 320 self.assertEqual(len(y), 1)
321 321
322 def test_deepcopy_keepalive(self): 322 def test_deepcopy_keepalive(self):
323 memo = {} 323 memo = {}
324 x = [] 324 x = 42
325 y = copy.deepcopy(x, memo) 325 y = copy.deepcopy(x, memo)
326 self.assertIs(memo[id(memo)][0], x) 326 self.assertTrue(memo[id(x)] is x)
327
328 def test_deepcopy_dont_memo_immutable(self):
329 memo = {}
330 x = [1, 2, 3, 4]
331 y = copy.deepcopy(x, memo)
332 self.assertEqual(y, x)
333 # There's the entry for the new list, and the keep alive.
334 self.assertEqual(len(memo), 2)
335
336 memo = {}
337 x = [(1, 2)]
338 y = copy.deepcopy(x, memo)
339 self.assertEqual(y, x)
340 # Tuples with immutable contents are immutable for deepcopy.
341 self.assertEqual(len(memo), 2)
342 327
343 def test_deepcopy_inst_vanilla(self): 328 def test_deepcopy_inst_vanilla(self):
344 class C: 329 class C:
345 def __init__(self, foo): 330 def __init__(self, foo):
346 self.foo = foo 331 self.foo = foo
347 def __eq__(self, other): 332 def __eq__(self, other):
348 return self.foo == other.foo 333 return self.foo == other.foo
349 x = C([42]) 334 x = C([42])
350 y = copy.deepcopy(x) 335 y = copy.deepcopy(x)
351 self.assertEqual(y, x) 336 self.assertEqual(y, x)
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 g.b() 709 g.b()
725 710
726 711
727 def global_foo(x, y): return x+y 712 def global_foo(x, y): return x+y
728 713
729 def test_main(): 714 def test_main():
730 support.run_unittest(TestCopy) 715 support.run_unittest(TestCopy)
731 716
732 if __name__ == "__main__": 717 if __name__ == "__main__":
733 test_main() 718 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_concurrent_futures.py ('k') | Lib/test/test_cprofile.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+