mò
­fIc           @   s  d  k  Z  d k l Z d k l Z l Z l Z l Z l Z l Z d k	 l	 Z	 d e  i
 f d „  ƒ  YZ d e  i
 f d „  ƒ  YZ d f  d	 „  ƒ  YZ d
 f  d „  ƒ  YZ d f  d „  ƒ  YZ d e  i
 f d „  ƒ  YZ d Z h  d e <Z d  d „ Z e d j o e d e ƒ n d  S(   N(   s   test_support(   s   bisect_rights   bisect_lefts   insort_lefts   insort_rights   insorts   bisect(   s   UserListt
   TestBisectc        X   B   sÒ  t  Z e g  d d f e d g d d f e d g d d f e d g d d f e d d g d d f e d d g d d f e d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d d g d d f e d d d d g d d f e d d d d g d d f e d d g d d f e d d g d d f e d d g d d f e d d g d d f e d d g d d f e d d d d g d d f e d d d d g d d f e d d d d g d d f e d d d d g d d f e d d d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d	 d f e d d d d d d d d d d g
 d d
 f e d d d d d d d d d d g
 d d
 f e g  d d f e d g d d f e d g d d f e d g d d f e d d g d d f e d d g d d f e d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d d g d d f e d d d d g d d f e d d d d g d d f e d d g d d f e d d g d d f e d d g d d f e d d g d d f e d d g d d f e d d d d g d d f e d d d d g d d f e d d d d g d d f e d d d d g d d f e d d d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d g d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d	 d f e d d d d d d d d d d g
 d d f e d d d d d d d d d d g
 d d
 f gN Z d „  Z d d „ Z d „  Z d „  Z d „  Z	 RS(   Ni   i    i   i   i   f1.5f2.5i   f3.5i
   i   c         C   s\   xU |  i D]J \ } } } } |  i | | | ƒ | ƒ |  i | t | ƒ | ƒ | ƒ q
 Wd  S(   N(   t   selft   precomputedCasest   funct   datat   elemt   expectedt   assertEqualt   UserList(   R   R   R   R   R   (    (    t-   /mit/python/lib/python2.4/test/test_bisect.pyt   test_precomputedZ   s    
 i   c   	      C   sJ  d k  l } x6t | ƒ D](} g  } t | ƒ D] } | | d | d ƒ q1 ~ } | i ƒ  | d | d ƒ } t
 | | ƒ } | t | ƒ j  o |  i | | | j ƒ n | d j o |  i | | d | j  ƒ n t | | ƒ } | t | ƒ j  o |  i | | | j  ƒ n | d j o |  i | | d | j ƒ q q Wd  S(   N(   s	   randrangei    i   iÿÿÿÿi   (   t   randomt	   randranget   xranget   nt   it   _[1]t   jR   t   sortR   t   bisect_leftt   ipt   lenR   t
   failUnlesst   bisect_right(	   R   R   R   R   R   R   R   R   R   (    (    R	   t   test_random_   s      3
c      
   C   s¶  x¯|  i D]¤\ } } } } xt d ƒ D]} t t	 | ƒ | ƒ } xct d d ƒ D]R} t t	 | ƒ | ƒ } | | | | | ƒ } |  i | | j o
 | j n ƒ | t j o( | | j  o |  i | | | j ƒ n | t j o, | | j o |  i | | d | j  ƒ n | t j o( | | j  o |  i | | | j  ƒ n | t j o, | | j o |  i | | d | j ƒ n |  i | t | t | | ƒ ƒ ƒ qT Wq) Wq
 Wd  S(   Ni   i   i   i   (   R   R   R   R   R   R   R   t   lot   minR   t   hiR   R   R   R   R   t   max(   R   R   R   R   R   R   R   R   (    (    R	   t   test_optionalSlicingp   s&    
   $c         C   s   |  i t t ƒ d  S(   N(   R   R   t   bisectR   (   R   (    (    R	   t   test_backcompatibility‚   s    c      
   C   s  d d d d d g } |  i t d | d d d	 d
 d d ƒ d ƒ |  i t d | d d d	 d
 d d ƒ d ƒ |  i t d | d d d	 d
 d d ƒ d ƒ t d | d d d	 d
 d d ƒ t d | d d d	 d
 d d ƒ t d | d d d	 d
 d d ƒ |  i | d d d d d d d d g ƒ d  S(   Ni
   i   i   i(   i2   t   at   xi   R   i   R   i   i   (	   R   R   R   R   R   R   t   insort_leftt   insort_rightt   insort(   R   R   (    (    R	   t   test_keyword_args…   s    +++(
   t   __name__t
   __module__R   R   R   R
   R   R   R   R%   (    (    (    R	   R       s   ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ¢R			t
   TestInsortc           B   s   t  Z d d „ Z d „  Z RS(   Niô  c         C   s‘   d k  l } xg t ƒ  t ƒ  f D]S } xJ t | ƒ D]< } | d ƒ } | d j o
 t	 } n t } | | | ƒ q3 Wq  W|  i t | ƒ | ƒ d  S(   N(   s   choicet
   0123456789t   02468(   R   t   choicet   listR   t   insortedR   R   R   t   digitR"   t   fR#   R   R   t   sorted(   R   R   R.   R/   R   R+   R-   (    (    R	   t   test_vsBuiltinSort“   s      
c         C   s   |  i t t ƒ d  S(   N(   R   R   R$   R#   (   R   (    (    R	   R   Ÿ   s    (   R&   R'   R1   R   (    (    (    R	   R(   ‘   s   t   LenOnlyc           B   s   t  Z d  Z d „  Z RS(   s:   Dummy sequence class defining __len__ but not __getitem__.c         C   s   d S(   Ni
   (    (   R   (    (    R	   t   __len__§   s    (   R&   R'   t   __doc__R3   (    (    (    R	   R2   ¥   s    t   GetOnlyc           B   s   t  Z d  Z d „  Z RS(   s:   Dummy sequence class defining __getitem__ but not __len__.c         C   s   d S(   Ni
   (    (   R   t   ndx(    (    R	   t   __getitem__¬   s    (   R&   R'   R4   R7   (    (    (    R	   R5   ª   s    t   CmpErrc           B   s   t  Z d  Z d „  Z RS(   s;   Dummy element that always raises an error during comparisonc         C   s
   t  ‚ d  S(   N(   t   ZeroDivisionError(   R   t   other(    (    R	   t   __cmp__±   s    (   R&   R'   R4   R;   (    (    (    R	   R8   ¯   s    t   TestErrorHandlingc           B   s5   t  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s7   x0 t  t t t f D] } |  i t | d d ƒ q Wd  S(   Ni
   (   R   R   R"   R#   R/   R   t   assertRaisest	   TypeError(   R   R/   (    (    R	   t   test_non_sequence¶   s     c         C   s:   x3 t  t t t f D] } |  i t | t ƒ  d ƒ q Wd  S(   Ni
   (	   R   R   R"   R#   R/   R   R=   t   AttributeErrorR2   (   R   R/   (    (    R	   t   test_len_onlyº   s     c         C   s:   x3 t  t t t f D] } |  i t | t ƒ  d ƒ q Wd  S(   Ni
   (	   R   R   R"   R#   R/   R   R=   R@   R5   (   R   R/   (    (    R	   t   test_get_only¾   s     c         C   sO   t  ƒ  t  ƒ  t  ƒ  g } x0 t t t t f D] } |  i t	 | | d ƒ q+ Wd  S(   Ni
   (
   R8   t   seqR   R   R"   R#   R/   R   R=   R9   (   R   RC   R/   (    (    R	   t   test_cmp_errÂ   s     c         C   s4   x- t  t t t f D] } |  i t | d ƒ q Wd  S(   Ni
   (   R   R   R"   R#   R/   R   R=   R>   (   R   R/   (    (    R	   t   test_arg_parsingÇ   s     (   R&   R'   R?   RA   RB   RD   RE   (    (    (    R	   R<   ´   s
   				s^  
Example from the Library Reference:  Doc/lib/libbisect.tex

The bisect() function is generally useful for categorizing numeric data.
This example uses bisect() to look up a letter grade for an exam total
(say) based on a set of ordered numeric breakpoints: 85 and up is an `A',
75..84 is a `B', etc.

    >>> grades = "FEDCBA"
    >>> breakpoints = [30, 44, 66, 75, 85]
    >>> from bisect import bisect
    >>> def grade(total):
    ...           return grades[bisect(breakpoints, total)]
    ...
    >>> grade(66)
    'C'
    >>> map(grade, [33, 99, 77, 44, 12, 88])
    ['E', 'A', 'B', 'D', 'F', 'A']

t
   libreftestc         C   së   d k  l } d k l } d  k } t t g } t t	 | ƒ o | i
 t ƒ n t i | Œ  t i | |  ƒ |  os t | d ƒ oc d  k } d  g d } xA t t | ƒ ƒ D]- } t i | Œ  | i ƒ  | i ƒ  | | <q­ W| GHn d  S(   N(   s   test_bisect(   s   BuiltinFunctionTypet   gettotalrefcounti   (   t   testt   test_bisectt   typest   BuiltinFunctionTypet   sysR    R(   t   test_classest
   isinstanceR   t   appendR<   t   test_supportt   run_unittestt   run_doctestt   verboset   hasattrt   gct   Nonet   countsR   R   R   t   collectRG   (   RS   R   RK   RL   RM   RU   RI   RW   (    (    R	   t	   test_mainæ   s"    		 
t   __main__RS   (   t   unittestRH   RP   R   R   R   R"   R#   R$   R   t   TestCaseR    R(   R2   R5   R8   R<   RF   t   __test__RV   RY   R&   t   True(   RP   RY   R#   R(   RF   R   R"   R   R[   R$   R    R   R2   R   R8   R]   R<   R5   (    (    R	   t   ?   s   	+‹