Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_bisect Namespace Reference

Classes

class  TestBisect
class  TestBisectPython
class  TestBisectC
class  TestInsort
class  TestInsortPython
class  TestInsortC
class  LenOnly
class  GetOnly
class  CmpErr
class  TestErrorHandling
class  TestErrorHandlingPython
class  TestErrorHandlingC

Functions

def test_main

Variables

string libreftest
dictionary __test__ = {'libreftest' : libreftest}

Function Documentation

def test.test_bisect.test_main (   verbose = None)

Definition at line 301 of file test_bisect.py.

00301 
00302 def test_main(verbose=None):
00303     from test import test_bisect
00304 
00305     test_classes = [TestBisectPython, TestBisectC,
00306                     TestInsortPython, TestInsortC,
00307                     TestErrorHandlingPython, TestErrorHandlingC]
00308 
00309     support.run_unittest(*test_classes)
00310     support.run_doctest(test_bisect, verbose)
00311 
00312     # verify reference counting
00313     if verbose and hasattr(sys, "gettotalrefcount"):
00314         import gc
00315         counts = [None] * 5
00316         for i in range(len(counts)):
00317             support.run_unittest(*test_classes)
00318             gc.collect()
00319             counts[i] = sys.gettotalrefcount()
00320         print(counts)


Variable Documentation

Definition at line 299 of file test_bisect.py.

Initial value:
00001 """
00002 Example from the Library Reference:  Doc/library/bisect.rst
00003 
00004 The bisect() function is generally useful for categorizing numeric data.
00005 This example uses bisect() to look up a letter grade for an exam total
00006 (say) based on a set of ordered numeric breakpoints: 85 and up is an `A',
00007 75..84 is a `B', etc.
00008 
00009     >>> grades = "FEDCBA"
00010     >>> breakpoints = [30, 44, 66, 75, 85]
00011     >>> from bisect import bisect
00012     >>> def grade(total):
00013     ...           return grades[bisect(breakpoints, total)]
00014     ...
00015     >>> grade(66)
00016     'C'
00017     >>> list(map(grade, [33, 99, 77, 44, 12, 88]))
00018     ['E', 'A', 'B', 'D', 'F', 'A']
00019 
00020 """

Definition at line 276 of file test_bisect.py.