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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 6 years, 7 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) 3 strip_python_stderr)
4 import sys 4 import sys
5 import time 5 import time
6 import gc 6 import gc
7 import weakref 7 import weakref
8 8
9 try: 9 try:
10 import threading 10 import threading
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 # Count that we got the right number of start and stop callbacks. 704 # Count that we got the right number of start and stop callbacks.
705 n = [v[1] for v in self.visit] 705 n = [v[1] for v in self.visit]
706 n1 = [i for i in n if i == "start"] 706 n1 = [i for i in n if i == "start"]
707 n2 = [i for i in n if i == "stop"] 707 n2 = [i for i in n if i == "stop"]
708 self.assertEqual(n1, ["start"]*2) 708 self.assertEqual(n1, ["start"]*2)
709 self.assertEqual(n2, ["stop"]*2) 709 self.assertEqual(n2, ["stop"]*2)
710 710
711 # Check that we got the right info dict for all callbacks 711 # Check that we got the right info dict for all callbacks
712 for v in self.visit: 712 for v in self.visit:
713 info = v[2] 713 info = v[2]
714 self.assertTrue("generation" in info) 714 self.assertIn("generation", info)
715 self.assertTrue("collected" in info) 715 self.assertIn("collected", info)
716 self.assertTrue("uncollectable" in info) 716 self.assertIn("uncollectable", info)
717 717
718 def test_collect_generation(self): 718 def test_collect_generation(self):
719 self.preclean() 719 self.preclean()
720 gc.collect(2) 720 gc.collect(2)
721 for v in self.visit: 721 for v in self.visit:
722 info = v[2] 722 info = v[2]
723 self.assertEqual(info["generation"], 2) 723 self.assertEqual(info["generation"], 2)
724 724
725 def test_collect_garbage(self): 725 def test_collect_garbage(self):
726 self.preclean() 726 self.preclean()
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 if verbose: 918 if verbose:
919 print("restoring automatic collection") 919 print("restoring automatic collection")
920 # make sure to always test gc.enable() 920 # make sure to always test gc.enable()
921 gc.enable() 921 gc.enable()
922 assert gc.isenabled() 922 assert gc.isenabled()
923 if not enabled: 923 if not enabled:
924 gc.disable() 924 gc.disable()
925 925
926 if __name__ == "__main__": 926 if __name__ == "__main__":
927 test_main() 927 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+