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

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

Issue 1953: Compact int and float freelists
Patch Set: Created 2 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/regrtest.py ('k') | Objects/floatobject.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- coding: iso-8859-1 -*- 1 # -*- coding: iso-8859-1 -*-
2 import unittest, test.test_support 2 import unittest, test.test_support
3 import sys, cStringIO 3 import sys, cStringIO
4 4
5 class SysModuleTest(unittest.TestCase): 5 class SysModuleTest(unittest.TestCase):
6 6
7 def test_original_displayhook(self): 7 def test_original_displayhook(self):
8 import __builtin__ 8 import __builtin__
9 savestdout = sys.stdout 9 savestdout = sys.stdout
10 out = cStringIO.StringIO() 10 out = cStringIO.StringIO()
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 self.failUnless(sys.flags) 356 self.failUnless(sys.flags)
357 attrs = ("debug", "py3k_warning", "division_warning", "division_new", 357 attrs = ("debug", "py3k_warning", "division_warning", "division_new",
358 "inspect", "interactive", "optimize", "dont_write_bytecode", 358 "inspect", "interactive", "optimize", "dont_write_bytecode",
359 "no_site", "ignore_environment", "tabcheck", "verbose", 359 "no_site", "ignore_environment", "tabcheck", "verbose",
360 "unicode") 360 "unicode")
361 for attr in attrs: 361 for attr in attrs:
362 self.assert_(hasattr(sys.flags, attr), attr) 362 self.assert_(hasattr(sys.flags, attr), attr)
363 self.assertEqual(type(getattr(sys.flags, attr)), int, attr) 363 self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
364 self.assert_(repr(sys.flags)) 364 self.assert_(repr(sys.flags))
365 365
366 def test_clear_type_cache(self):
367 sys.clear_type_cache()
368
369 def test_compact_freelists(self):
370 sys.compact_freelists()
371 r = sys.compact_freelists()
372 # freed blocks shouldn't change
373 self.assertEqual(r[0][2], 0)
374 self.assertEqual(r[1][2], 0)
375 # fill freelists
376 ints = list(range(12000))
377 floats = [float(i) for i in ints]
378 del ints
379 del floats
380 # should free more than 200 blocks each
381 r = sys.compact_freelists()
382 self.assert_(r[0][2] > 200, r[0][2])
383 self.assert_(r[1][2] > 200, r[1][2])
366 384
367 def test_main(): 385 def test_main():
368 test.test_support.run_unittest(SysModuleTest) 386 test.test_support.run_unittest(SysModuleTest)
369 387
370 if __name__ == "__main__": 388 if __name__ == "__main__":
371 test_main() 389 test_main()
OLDNEW
« no previous file with comments | « Lib/test/regrtest.py ('k') | Objects/floatobject.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7