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

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

Issue 602: range: lean and mean (Closed) SVN Base: http://svn.python.org/view/*checkout*/python/branches/py3k/
Patch Set: address more concerns Created 1 year, 7 months ago , Downloaded from: http://bugs.python.org/file10183/range_lean_and_mean5.patch
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
OLDNEW
1 """Unittests for heapq.""" 1 """Unittests for heapq."""
2 2
3 import random 3 import random
4 import unittest 4 import unittest
5 from test import test_support 5 from test import test_support
6 import sys 6 import sys
7 7
8 # We do a bit of trickery here to be able to test both the C implementation 8 # We do a bit of trickery here to be able to test both the C implementation
9 # and the Python implementation of the module. 9 # and the Python implementation of the module.
10 10
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 self.assertRaises(ZeroDivisionError, f, 2, seq) 330 self.assertRaises(ZeroDivisionError, f, 2, seq)
331 331
332 def test_arg_parsing(self): 332 def test_arg_parsing(self):
333 for f in (self.module.heapify, self.module.heappop, 333 for f in (self.module.heapify, self.module.heappop,
334 self.module.heappush, self.module.heapreplace, 334 self.module.heappush, self.module.heapreplace,
335 self.module.nlargest, self.module.nsmallest): 335 self.module.nlargest, self.module.nsmallest):
336 self.assertRaises(TypeError, f, 10) 336 self.assertRaises(TypeError, f, 10)
337 337
338 def test_iterable_args(self): 338 def test_iterable_args(self):
339 for f in (self.module.nlargest, self.module.nsmallest): 339 for f in (self.module.nlargest, self.module.nsmallest):
340 for s in ("123", "", range(1000), (1, 1.2), range(2000,2200,5)): 340 for s in ("123", "", (1, 1.2)):
341 for g in (G, I, Ig, L, R): 341 for g in (G, I, Ig, L, R):
342 self.assertEqual(list(f(2, g(s))), list(f(2,s))) 342 self.assertEqual(list(f(2, g(s))), list(f(2,s)))
343 self.assertEqual(list(f(2, S(s))), []) 343 self.assertEqual(list(f(2, S(s))), [])
344 self.assertRaises(TypeError, f, 2, X(s)) 344 self.assertRaises(TypeError, f, 2, X(s))
345 self.assertRaises(TypeError, f, 2, N(s)) 345 self.assertRaises(TypeError, f, 2, N(s))
346 self.assertRaises(ZeroDivisionError, f, 2, E(s)) 346 self.assertRaises(ZeroDivisionError, f, 2, E(s))
347 347
348 348
349 #============================================================================== 349 #==============================================================================
350 350
351 351
352 def test_main(verbose=None): 352 def test_main(verbose=None):
353 from types import BuiltinFunctionType 353 from types import BuiltinFunctionType
354 354
355 test_classes = [TestHeapPython, TestHeapC, TestErrorHandling] 355 test_classes = [TestHeapPython, TestHeapC, TestErrorHandling]
356 test_support.run_unittest(*test_classes) 356 test_support.run_unittest(*test_classes)
357 357
358 # verify reference counting 358 # verify reference counting
359 if verbose and hasattr(sys, "gettotalrefcount"): 359 if verbose and hasattr(sys, "gettotalrefcount"):
360 import gc 360 import gc
361 counts = [None] * 5 361 counts = [None] * 5
362 for i in range(len(counts)): 362 for i in range(len(counts)):
363 test_support.run_unittest(*test_classes) 363 test_support.run_unittest(*test_classes)
364 gc.collect() 364 gc.collect()
365 counts[i] = sys.gettotalrefcount() 365 counts[i] = sys.gettotalrefcount()
366 print(counts) 366 print(counts)
367 367
368 if __name__ == "__main__": 368 if __name__ == "__main__":
369 test_main(verbose=True) 369 test_main(verbose=True)
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r497