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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 10 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_functools.py ('k') | Lib/test/test_gdb.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 import unittest 1 import unittest
2 from test.support import (verbose, refcount_test, run_unittest, 2 from test.support import (verbose, refcount_test, run_unittest,
3 strip_python_stderr, cpython_only) 3 strip_python_stderr, cpython_only)
4 from test.script_helper import assert_python_ok, make_script, temp_dir 4 from test.script_helper import assert_python_ok, make_script, temp_dir
5 5
6 import sys 6 import sys
7 import time 7 import time
8 import gc 8 import gc
9 import weakref 9 import weakref
10 10
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 # Count that we got the right number of start and stop callbacks. 757 # Count that we got the right number of start and stop callbacks.
758 n = [v[1] for v in self.visit] 758 n = [v[1] for v in self.visit]
759 n1 = [i for i in n if i == "start"] 759 n1 = [i for i in n if i == "start"]
760 n2 = [i for i in n if i == "stop"] 760 n2 = [i for i in n if i == "stop"]
761 self.assertEqual(n1, ["start"]*2) 761 self.assertEqual(n1, ["start"]*2)
762 self.assertEqual(n2, ["stop"]*2) 762 self.assertEqual(n2, ["stop"]*2)
763 763
764 # Check that we got the right info dict for all callbacks 764 # Check that we got the right info dict for all callbacks
765 for v in self.visit: 765 for v in self.visit:
766 info = v[2] 766 info = v[2]
767 self.assertTrue("generation" in info) 767 self.assertIn("generation", info)
768 self.assertTrue("collected" in info) 768 self.assertIn("collected", info)
769 self.assertTrue("uncollectable" in info) 769 self.assertIn("uncollectable", info)
770 770
771 def test_collect_generation(self): 771 def test_collect_generation(self):
772 self.preclean() 772 self.preclean()
773 gc.collect(2) 773 gc.collect(2)
774 for v in self.visit: 774 for v in self.visit:
775 info = v[2] 775 info = v[2]
776 self.assertEqual(info["generation"], 2) 776 self.assertEqual(info["generation"], 2)
777 777
778 @cpython_only 778 @cpython_only
779 def test_collect_garbage(self): 779 def test_collect_garbage(self):
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 if verbose: 972 if verbose:
973 print("restoring automatic collection") 973 print("restoring automatic collection")
974 # make sure to always test gc.enable() 974 # make sure to always test gc.enable()
975 gc.enable() 975 gc.enable()
976 assert gc.isenabled() 976 assert gc.isenabled()
977 if not enabled: 977 if not enabled:
978 gc.disable() 978 gc.disable()
979 979
980 if __name__ == "__main__": 980 if __name__ == "__main__":
981 test_main() 981 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_functools.py ('k') | Lib/test/test_gdb.py » ('j') | no next file with comments »

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