ó
&Ú#\c           @   sÁ  d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d  d l Z	 d „  Z
 d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d  „  ƒ  YZ d! e f d" „  ƒ  YZ d# e f d$ „  ƒ  YZ d% e f d& „  ƒ  YZ d' e f d( „  ƒ  YZ d) e f d* „  ƒ  YZ d+ e f d, „  ƒ  YZ d- e f d. „  ƒ  YZ d/ e f d0 „  ƒ  YZ d1 e f d2 „  ƒ  YZ  d3 e f d4 „  ƒ  YZ! d5 e f d6 „  ƒ  YZ" d7 e f d8 „  ƒ  YZ# d9 e f d: „  ƒ  YZ$ d; e f d< „  ƒ  YZ% d= e f d> „  ƒ  YZ& d S(?   iÿÿÿÿ(   t   DocTestSuite(   t   TestCase(   t   combinations(   t   rangeNc         C   s   | j  t d ƒ ƒ | S(   Ns   more_itertools.recipes(   t   addTestsR    (   t   loadert   testst   ignore(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt
   load_tests
   s    t   AccumulateTestsc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``accumulate()``c         C   s#   |  j  t t j g  ƒ ƒ g  ƒ d S(   s0   Test that an empty input returns an empty outputN(   t   assertEqualt   listt   mit
   accumulate(   t   self(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt
   test_empty   s    c         C   s5   |  j  t t j d d d g ƒ ƒ d d d g ƒ d S(   s4   Test accumulate with the default function (addition)i   i   i   i   N(   R
   R   R   R   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_default   s    c      	   C   s?   |  j  t ƒ * t t j d d d g d d „  ƒƒ Wd QXd S(   s(   Test accumulate with an invalid functioni   i   i   t   funcc         S   s   |  S(   N(    (   t   x(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   <lambda>   s    N(   t   assertRaisest	   TypeErrorR   R   R   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_bogus_function   s    c         C   s8   |  j  t t j d d t ƒƒ d d d d d g ƒ d S(   s&   Test accumulate with a custom functioni   i   i   R   N(   i   i   i   i   i   (   R
   R   R   R   t   max(   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_custom_function    s    (   t   __name__t
   __module__t   __doc__R   R   R   R   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR	      s
   			t	   TakeTestsc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``take()``c         C   s;   t  j d t d ƒ ƒ } |  j | d d d d d g ƒ d S(	   s   Test basic usagei   i
   i    i   i   i   i   N(   R   t   takeR   R
   (   R   t   t(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_simple_take*   s    c         C   s,   t  j d t d ƒ ƒ } |  j | g  ƒ d S(   s   Check the null casei    i
   N(   R   R   R   R
   (   R   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_null_take/   s    c         C   s   |  j  t d „  ƒ d S(   s7   Make sure taking negative items results in a ValueErrorc           S   s   t  j d t d ƒ ƒ S(   Niýÿÿÿi
   (   R   R   R   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   6   s    N(   R   t
   ValueError(   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_negative_take4   s    c         C   s;   t  j d t d ƒ ƒ } |  j | d d d d d g ƒ d S(	   sk   Taking more than an iterator has remaining should return what the
        iterator has remaining.

        i
   i   i    i   i   i   i   N(   R   R   R   R
   (   R   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_take_too_much8   s    (   R   R   R   R   R    R"   R#   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   '   s
   			t   TabulateTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s   Tests for ``tabulate()``c         C   sQ   t  j d „  ƒ } t g  t d ƒ D] } t | ƒ ^ q" ƒ } |  j | d ƒ d S(   s   Test the happy pathc         S   s   |  S(   N(    (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   F   s    i   i    i   i   N(   i    i   i   (   R   t   tabulatet   tupleR   t   nextR
   (   R   R   t   _t   f(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_simple_tabulateD   s    +c         C   sJ   t  j d „  d ƒ } t | ƒ t | ƒ t | ƒ f } |  j | d ƒ d S(   s&   Ensure tabulate accepts specific countc         S   s   d |  S(   Ni   (    (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   L   s    iÿÿÿÿiþÿÿÿi    i   N(   iþÿÿÿi    i   (   R   R%   R'   R
   (   R   R   R)   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt
   test_countJ   s    !(   R   R   R   R*   R+   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR$   A   s   	t	   TailTestsc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``tail()``c         C   s/   |  j  t t j d d ƒ ƒ d d d g ƒ d S(   s1   Length of iterable is greater than requested taili   t   ABCDEFGt   Et   Ft   GN(   R
   R   R   t   tail(   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_greaterT   s    c      	   C   s;   |  j  t t j d d ƒ ƒ d d d d d d d	 g ƒ d
 S(   s1   Length of iterable is equal to the requested taili   R-   t   At   Bt   Ct   DR.   R/   R0   N(   R
   R   R   R1   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt
   test_equalX   s    c      	   C   s;   |  j  t t j d d ƒ ƒ d d d d d d d	 g ƒ d
 S(   s.   Length of iterable is less than requested taili   R-   R3   R4   R5   R6   R.   R/   R0   N(   R
   R   R   R1   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt	   test_less^   s    (   R   R   R   R2   R7   R8   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR,   Q   s   		t   ConsumeTestsc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``consume()``c         C   s@   d „  t  d ƒ Dƒ } t j | d ƒ |  j d t | ƒ ƒ d S(   s   Test basic functionalityc         s   s   |  ] } | Vq d  S(   N(    (   t   .0R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pys	   <genexpr>j   s    i
   i   N(   R   R   t   consumeR
   R'   (   R   t   r(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_sanityh   s    c         C   s@   d „  t  d ƒ Dƒ } t j | d ƒ |  j d t | ƒ ƒ d S(   s   Check the null casec         s   s   |  ] } | Vq d  S(   N(    (   R:   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pys	   <genexpr>p   s    i
   i    N(   R   R   R;   R
   R'   (   R   R<   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_null_consumen   s    c            s3   d „  t  d ƒ Dƒ ‰  |  j t ‡  f d †  ƒ d S(   s.   Check that negative consumsion throws an errorc         s   s   |  ] } | Vq d  S(   N(    (   R:   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pys	   <genexpr>v   s    i
   c              s   t  j ˆ  d ƒ S(   Niÿÿÿÿ(   R   R;   (    (   R<   (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   w   s    N(   R   R   R!   (   R   (    (   R<   s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_negative_consumet   s    c            s@   d „  t  d ƒ Dƒ ‰  t j ˆ  ƒ |  j t ‡  f d †  ƒ d S(   s2   Check that iterator is totally consumed by defaultc         s   s   |  ] } | Vq d  S(   N(    (   R:   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pys	   <genexpr>{   s    i
   c              s
   t  ˆ  ƒ S(   N(   R'   (    (   R<   (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   }   s    N(   R   R   R;   R   t   StopIteration(   R   (    (   R<   s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_total_consumey   s    (   R   R   R   R=   R>   R?   RA   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR9   e   s
   			t   NthTestsc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``nth()``c         C   sI   t  d ƒ } x6 t | ƒ D]( \ } } |  j t j | | ƒ | ƒ q Wd S(   s"   Make sure the nth item is returnedi
   N(   R   t	   enumerateR
   R   t   nth(   R   t   lt   it   v(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt
   test_basicƒ   s    c         C   s/   t  d ƒ } |  j t j | d d ƒ d ƒ d S(   s:   Ensure a default value is returned when nth item not foundi   id   t   zebraN(   R   R
   R   RD   (   R   RE   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   ‰   s    c         C   s   |  j  t d „  ƒ d S(   s5   Ensure asking for a negative item raises an exceptionc           S   s   t  j t d ƒ d ƒ S(   Ni
   iýÿÿÿ(   R   RD   R   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR      s    N(   R   R!   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_negative_item_raisesŽ   s    (   R   R   R   RH   R   RJ   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRB   €   s   		t   AllEqualTestsc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``all_equal()``c         C   s<   |  j  t j d ƒ ƒ |  j  t j d d d d g ƒ ƒ d S(   s   Everything is equalt   aaaaaai    N(   t
   assertTrueR   t	   all_equal(   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt	   test_true–   s    c         C   s<   |  j  t j d ƒ ƒ |  j  t j d d d d g ƒ ƒ d S(   s   Not everything is equalt   aaaaabi    i   N(   t   assertFalseR   RN   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt
   test_false›   s    c         C   s2   d t  d d ƒ d g } |  j t j | ƒ ƒ d S(   s4   Not everything is identical, but everything is equali   i    g      ð?N(   t   complexRM   R   RN   (   R   t   items(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_tricky    s    c         C   s0   |  j  t j d ƒ ƒ |  j  t j g  ƒ ƒ d S(   s$   Return True if the iterable is emptyt    N(   RM   R   RN   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   ¥   s    c         C   s3   |  j  t j d ƒ ƒ |  j  t j d g ƒ ƒ d S(   s'   Return True if the iterable is singulart   0i    N(   RM   R   RN   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_oneª   s    (   R   R   R   RO   RR   RU   R   RX   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRK   “   s   				t   QuantifyTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s   Tests for ``quantify()``c         C   s,   t  t t  g } |  j t j | ƒ d ƒ d S(   s    Make sure True count is returnedi   N(   t   Truet   FalseR
   R   t   quantify(   R   t   q(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_happy_path³   s    c         C   s/   t  d ƒ } |  j t j | d „  ƒ d ƒ d S(   s0   Ensure non-default predicates return as expectedi
   c         S   s   |  d d k S(   Ni   i    (    (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   »   s    i   N(   R   R
   R   R\   (   R   R]   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_custom_predicate¸   s    (   R   R   R   R^   R_   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRY   °   s   	t   PadnoneTestsc           B   s   e  Z d  Z d „  Z RS(   s   Tests for ``padnone()``c         C   sZ   t  d ƒ } t j | ƒ } |  j d d d d g g  t  d ƒ D] } t | ƒ ^ q= ƒ d S(   s0   wrapper iterator should return None indefinitelyi   i    i   i   N(   R   R   t   padnoneR
   t   NoneR'   (   R   R<   t   pR(   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR^   Á   s    (   R   R   R   R^   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR`   ¾   s   t   NcyclesTestsc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``nyclces()``c      
   C   sV   d d d g } t  j | d ƒ } |  j d d d d d d d d d g	 t | ƒ ƒ d S(   s   cycle a sequence three timest   at   bt   ci   N(   R   t   ncyclesR
   R   (   R   R<   t   n(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR^   Ë   s
    c            s5   t  j t d ƒ d ƒ ‰  |  j t ‡  f d †  ƒ d S(   s3   asking for 0 cycles should return an empty iteratorid   i    c              s
   t  ˆ  ƒ S(   N(   R'   (    (   Ri   (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   ×   s    N(   R   Rh   R   R   R@   (   R   (    (   Ri   s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_null_caseÔ   s    c            s5   t  j t d ƒ d ƒ ‰  |  j t ‡  f d †  ƒ d S(   s:   asking for negative cycles should return an empty iteratorid   iöÿÿÿc              s
   t  ˆ  ƒ S(   N(   R'   (    (   Ri   (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   Ü   s    N(   R   Rh   R   R   R@   (   R   (    (   Ri   s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_pathalogical_caseÙ   s    (   R   R   R   R^   Rj   Rk   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRd   È   s   			t   DotproductTestsc           B   s   e  Z d  Z d „  Z RS(   s   Tests for ``dotproduct()``'c         C   s,   |  j  d t j d d g d d g ƒ ƒ d S(   s   simple dotproduct examplei  i
   i   N(   R
   R   t
   dotproduct(   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR^   â   s    (   R   R   R   R^   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRl   ß   s   t   FlattenTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s   Tests for ``flatten()``c         C   sM   d d d g d d d g g } |  j  t t d ƒ ƒ t t j | ƒ ƒ ƒ d S(	   s+   ensure list of lists is flattened one leveli    i   i   i   i   i   i   N(   R
   R   R   R   t   flatten(   R   R)   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_basic_usageê   s    c         C   s_   d d d g g d d g d g g } |  j  d d d g d d g d g t t j | ƒ ƒ ƒ d S(   s0   ensure list of lists is flattened only one leveli    i   i   i   i   i   N(   R
   R   R   Ro   (   R   R)   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_single_levelï   s    $(   R   R   R   Rp   Rq   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRn   ç   s   	t   RepeatfuncTestsc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``repeatfunc()``c         C   sT   t  j d „  ƒ } |  j d d d d d g g  t d ƒ D] } t | ƒ ^ q7 ƒ d S(   s   test simple repeated functionsc           S   s   d S(   Ni   (    (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   ú   s    i   N(   R   t
   repeatfuncR
   R   R'   (   R   R<   R(   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_simple_repeatø   s    c         C   sA   t  j d „  d d ƒ} |  j d d d d d g t | ƒ ƒ d S(   s,   ensure limited repeat when times is providedc           S   s   d S(   Ni   (    (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   ÿ   s    t   timesi   N(   R   Rs   R
   R   (   R   R<   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_finite_repeatý   s    c         C   s8   t  j d „  d d ƒ } |  j d d g t | ƒ ƒ d S(   s,   ensure arguments are applied to the functionc         S   s   |  S(   N(    (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR     s    i   i   N(   R   Rs   R
   R   (   R   R<   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_added_arguments  s    c            s2   t  j t d d ƒ ‰  |  j t ‡  f d †  ƒ d S(   s(   repeat 0 should return an empty iteratori    i   c              s
   t  ˆ  ƒ S(   N(   R'   (    (   R<   (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   
  s    N(   R   Rs   R   R   R@   (   R   (    (   R<   s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_null_times  s    (   R   R   R   Rt   Rv   Rw   Rx   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRr   õ   s
   			t   PairwiseTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s   Tests for ``pairwise()``c         C   s8   t  j d d d g ƒ } |  j d d g t | ƒ ƒ d S(   s'   ensure an iterable will return pairwisei   i   i   N(   i   i   (   i   i   (   R   t   pairwiseR
   R   (   R   Rc   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_base_case  s    c            s,   t  j d ƒ ‰  |  j t ‡  f d †  ƒ d S(   s=   ensure an empty iterator if there's not enough values to pairRe   c              s
   t  ˆ  ƒ S(   N(   R'   (    (   Rc   (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR     s    N(   R   Rz   R   R@   (   R   (    (   Rc   s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_short_case  s    (   R   R   R   R{   R|   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRy     s   	t   GrouperTestsc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``grouper()``c         C   s,   |  j  t t j d d ƒ ƒ d
 d g ƒ d	 S(   sV   Test when group size divides evenly into the length of
        the iterable.

        i   t   ABCDEFR3   R4   R5   R6   R.   R/   N(   R3   R4   R5   (   R6   R.   R/   (   R
   R   R   t   grouper(   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt	   test_even  s    c         C   s,   |  j  t t j d d ƒ ƒ d	 d
 g ƒ d S(   s^   Test when group size does not divide evenly into the length of the
        iterable.

        i   t   ABCDER3   R4   R5   R6   R.   N(   R3   R4   R5   (   R6   R.   N(   R
   R   R   R   Rb   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_odd'  s    c         C   s/   |  j  t t j d d d ƒ ƒ d
 d g ƒ d	 S(   s7   Test that the fill value is used to pad the final groupi   R   R   R3   R4   R5   R6   R.   N(   R3   R4   R5   (   R6   R.   R   (   R
   R   R   R   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_fill_value0  s    (   R   R   R   R€   R‚   Rƒ   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR}     s   				t   RoundrobinTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s   Tests for ``roundrobin()``c         C   sS   |  j  t t j d d d d g t d ƒ ƒ ƒ d d d d d d d d d g	 ƒ d	 S(
   s5   Ensure ordered output from evenly populated iterablest   ABCi   i   i   R3   i    R4   R5   N(   R
   R   R   t
   roundrobinR   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_even_groups;  s    'c         C   sG   |  j  t t j d d d g t d ƒ ƒ ƒ d d d d d d g ƒ d	 S(
   s7   Ensure ordered output from unevenly populated iterablest   ABCDi   i   i    R3   R4   R5   R6   N(   R
   R   R   R†   R   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_uneven_groupsB  s    $(   R   R   R   R‡   R‰   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR„   8  s   	t   PartitionTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s   Tests for ``partition()``c         C   so   t  j d „  t d ƒ ƒ \ } } |  j t | ƒ d d d d d d g ƒ |  j t | ƒ d	 d
 d d g ƒ d S(   s"   Test when pred() returns a booleanc         S   s
   |  d k S(   Ni   (    (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   O  s    i
   i    i   i   i   i   i   i   i   i   i	   N(   R   t	   partitionR   R
   R   (   R   t   lessert   greater(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt	   test_boolM  s    !(c         C   so   t  j d „  t d ƒ ƒ \ } } |  j t | ƒ d d d d g ƒ |  j t | ƒ d d d	 d
 d d g ƒ d S(   s#   Test when pred() returns an integerc         S   s   |  d S(   Ni   (    (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   U  s    i
   i    i   i   i	   i   i   i   i   i   i   N(   R   R‹   R   R
   R   (   R   t
   divisiblest
   remainders(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_arbitraryS  s    !"(   R   R   R   RŽ   R‘   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRŠ   J  s   	t   PowersetTestsc           B   s   e  Z d  Z d „  Z RS(   s   Tests for ``powerset()``c         C   sJ   t  j d d d g ƒ } |  j t | ƒ d d d d d	 d
 d d g ƒ d S(   s   Ensure a proper enumerationi   i   i   N(    (   i   (   i   (   i   (   i   i   (   i   i   (   i   i   (   i   i   i   (   R   t   powersetR
   R   (   R   Rc   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_combinatorics]  s    	(   R   R   R   R”   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR’   Z  s   t   UniqueEverseenTestsc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``unique_everseen()``c         C   s5   t  j d ƒ } |  j d d d d g t | ƒ ƒ d S(   s%   ensure duplicate elements are ignoredt   AAAABBBBCCDAABBBR3   R4   R5   R6   N(   R   t   unique_everseenR
   R   (   R   t   u(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_everseeni  s    c         C   s8   t  j d d t j ƒ} |  j t d ƒ t | ƒ ƒ d S(   s&   ensure the custom key comparison workst   aAbACCct   keyt   abCN(   R   R—   t   strt   lowerR
   R   (   R   R˜   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_custom_keyq  s    c         C   s\   d d d d g d d d g d g } t  j | ƒ } |  j t | ƒ d d d d g g ƒ d S(   s'   ensure things work for unhashable itemsRe   i   i   i   N(   R   R—   R
   R   (   R   t   iterableR˜   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_unhashablev  s    $c         C   se   d d d d g d d d g d g } t  j | d d „  ƒ} |  j t | ƒ d d d d g g ƒ d S(   s9   ensure things work for unhashable items with a custom keyRe   i   i   i   R›   c         S   s   |  S(   N(    (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR     s    N(   R   R—   R
   R   (   R   R    R˜   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_unhashable_key|  s    $(   R   R   R   R™   RŸ   R¡   R¢   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR•   f  s
   			t   UniqueJustseenTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s   Tests for ``unique_justseen()``c         C   s/   t  j d ƒ } |  j t d ƒ t | ƒ ƒ d S(   s#   ensure only last item is rememberedt   AAAABBBCCDABBt   ABCDABN(   R   t   unique_justseenR
   R   (   R   R˜   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_justseen†  s    c         C   s5   t  j d t j ƒ } |  j t d ƒ t | ƒ ƒ d S(   s&   ensure the custom key comparison workst   AABCcADt   ABCADN(   R   R¦   R   Rž   R
   R   (   R   R˜   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRŸ   ‹  s    (   R   R   R   R§   RŸ   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR£   ƒ  s   	t   IterExceptTestsc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``iter_except()``c         C   sG   d d d g } t  j | j t ƒ } |  j t | ƒ d d d g ƒ d S(   s.   ensure the exact specified exception is caughti   i   i   N(   R   t   iter_exceptt   popt
   IndexErrorR
   R   (   R   RE   RF   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_exact_exception”  s    c         C   sA   d d g } t  j | j t ƒ } |  j t | ƒ d d g ƒ d S(   s*   ensure the generic exception can be caughti   i   N(   R   R«   R¬   t	   ExceptionR
   R   (   R   RE   RF   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_generic_exceptionš  s    c            sA   d d d g } t  j | j t ƒ ‰  |  j t ‡  f d †  ƒ d S(   s*   ensure a non-specified exception is raisedi   i   i   c              s
   t  ˆ  ƒ S(   N(   R   (    (   RF   (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   ¤  s    N(   R   R«   R¬   t   KeyErrorR   R­   (   R   RE   (    (   RF   s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt!   test_uncaught_exception_is_raised   s    c         C   sV   d d d g } d „  } t  j | j t | ƒ } |  j t | ƒ d d d d g ƒ d S(   s'   ensure first is run before the functioni   i   i   c           S   s   d S(   Ni   (    (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   ©  s    i   N(   R   R«   R¬   R­   R
   R   (   R   RE   R)   RF   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt
   test_first¦  s    	(   R   R   R   R®   R°   R²   R³   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRª   ‘  s
   			t   FirstTrueTestsc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Tests for ``first_true()``c         C   s#   |  j  t j t d ƒ ƒ d ƒ d S(   s   Test with no keywordsi
   i   N(   R
   R   t
   first_trueR   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_something_true±  s    c         C   s#   |  j  t j d d d g ƒ ƒ d S(   s   Test default return value.i    N(   t   assertIsNoneR   Rµ   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_nothing_trueµ  s    c         C   s,   |  j  t j d d d g d d ƒd ƒ d S(   s   Test with a default keywordi    t   defaultt   !N(   R
   R   Rµ   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   ¹  s    c         C   s/   |  j  t j d d d g d d „  ƒd ƒ d S(   s   Test with a custom predicatei   i   i   t   predc         S   s   |  d d k S(   Ni   i    (    (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   À  s    N(   R
   R   Rµ   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt	   test_pred½  s    (   R   R   R   R¶   R¸   R   R¼   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR´   ®  s
   			t   RandomProductTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   së   Tests for ``random_product()``

    Since random.choice() has different results with the same seed across
    python versions 2.x and 3.x, these tests use highly probably events to
    create predictable outcomes across platforms.
    c         C   sÖ   d d d g } d d d g } t  g  t d ƒ D] } t j | | ƒ ^ q. Œ  \ } } t | ƒ t | ƒ } } |  j | t | ƒ ƒ |  j | t | ƒ ƒ |  j t | ƒ t | ƒ ƒ |  j t | ƒ t | ƒ ƒ d S(	   s  Ensure that one item is chosen from each list in each pair.
        Also ensure that each item from each list eventually appears in
        the chosen combinations.

        Odds are roughly 1 in 7.1 * 10e16 that one item from either list will
        not be chosen after 100 samplings of one item from each list. Just to
        be safe, better use a known random seed, too.

        i   i   i   Re   Rf   Rg   id   N(   t   zipR   R   t   random_productt   setR
   t   len(   R   t   numst   letsR(   Ri   t   m(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_simple_listsÌ  s    
7c         C   sí   d d d g } d d d g } t  t j | | d d ƒƒ } |  j d
 t | ƒ ƒ t | d	 d	 d … ƒ t | d d	 d … ƒ } } |  j | t | ƒ ƒ |  j | t | ƒ ƒ |  j t | ƒ t | ƒ ƒ |  j t | ƒ t | ƒ ƒ d	 S(   sƒ   ensure multiple items are chosen, and that they appear to be chosen
        from one list then the next, in proper order.

        i   i   i   Re   Rf   Rg   t   repeatid   NiÈ   (   R   R   R¿   R
   RÁ   RÀ   (   R   RÂ   RÃ   R<   Ri   RÄ   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_list_with_repeatß  s    3(   R   R   R   RÅ   RÇ   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR½   Ä  s   	t   RandomPermutationTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s"   Tests for ``random_permutation()``c         C   sV   t  d ƒ } t j | ƒ } |  j t | ƒ t | ƒ ƒ | | k rR t d ƒ ‚ n  d S(   sÆ   ensure every item from the iterable is returned in a new ordering

        15 elements have a 1 in 1.3 * 10e12 of appearing in sorted order, so
        we fix a seed value just to be sure.

        i   s   Values were not permutedN(   R   R   t   random_permutationR
   RÀ   t   AssertionError(   R   RF   R<   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_full_permutationò  s
    c         C   sš   t  d ƒ } t | ƒ } t ƒ  } xb t  d ƒ D]T } t j | d ƒ } |  j t | ƒ d ƒ t | ƒ } |  j | | ƒ | | O} q. W|  j | | ƒ d S(   sÙ  ensure all returned items are from the iterable, that the returned
        permutation is of the desired length, and that all items eventually
        get returned.

        Sampling 100 permutations of length 5 from a set of 15 leaves a
        (2/3)^100 chance that an item will not be chosen. Multiplied by 15
        items, there is a 1 in 2.6e16 chance that at least 1 item will not
        show up in the resulting output. Using a random seed will fix that.

        i   id   i   N(   R   RÀ   R   RÉ   R
   RÁ   t   assertLessEqual(   R   RT   t   item_sett	   all_itemsR(   t   permutationt   permutation_set(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_partial_permutationÿ  s    	(   R   R   R   RË   RÑ   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRÈ   ï  s   	t   RandomCombinationTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s"   Tests for ``random_combination()``c         C   sh   t  d ƒ } t ƒ  } x6 t  d ƒ D]( } t j | d ƒ } | t | ƒ O} q" W|  j | t | ƒ ƒ d S(   sh   ensure different subsets of the iterable get returned over many
        samplings of random combinationsi   i2   i   N(   R   RÀ   R   t   random_combinationR
   (   R   RT   RÎ   R(   t   combination(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_pseudorandomness  s    	c            sz   t  d ƒ ‰  xN t  d ƒ D]@ } t j ˆ  t ˆ  ƒ ƒ } |  j t | ƒ t t | ƒ ƒ ƒ q W|  j t ‡  f d †  ƒ d S(   s4   ensure that elements are sampled without replacementi   i2   c              s   t  j ˆ  t ˆ  ƒ d ƒ S(   Ni   (   R   RÓ   RÁ   (    (   RT   (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR   *  s    N(   R   R   RÓ   RÁ   R
   RÀ   R   R!   (   R   R(   RÔ   (    (   RT   s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_no_replacement#  s    &(   R   R   R   RÕ   RÖ   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRÒ     s   	
t%   RandomCombinationWithReplacementTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s3   Tests for ``random_combination_with_replacement()``c         C   sy   t  d ƒ } t j | t | ƒ d ƒ } |  j d t | ƒ t | ƒ ƒ t t | ƒ ƒ t | ƒ k ru t d ƒ ‚ n  d S(   s1   ensure that elements are sampled with replacementi   i   s#   Combination contained no duplicatesN(   R   R   t#   random_combination_with_replacementRÁ   R
   RÀ   RÊ   (   R   RT   t   combo(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_replacement1  s
     c         C   sh   t  d ƒ } t ƒ  } x6 t  d ƒ D]( } t j | d ƒ } | t | ƒ O} q" W|  j | t | ƒ ƒ d S(   sh   ensure different subsets of the iterable get returned over many
        samplings of random combinationsi   i2   i   N(   R   RÀ   R   RØ   R
   (   R   RT   RÎ   R(   RÔ   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRÕ   9  s    	(   R   R   R   RÚ   RÕ   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyR×   .  s   	t   NthCombinationTestsc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s[   d } d } xH t  t | | ƒ ƒ D]1 \ } } t j | | | ƒ } |  j | | ƒ q" Wd  S(   Nt   abcdefgi   (   RC   R   R   t   nth_combinationR
   (   R   R    R<   t   indext   expectedt   actual(    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRH   E  s
    "c         C   s5   t  j t d ƒ d d ƒ } d } |  j | | ƒ d  S(	   Ni´   i   i€„ i   i   i#   i~   (   i   i   i#   i~   (   R   RÝ   R   R
   (   R   Rà   Rß   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt	   test_longL  s    c      	   C   s>   x7 d D]/ } |  j  t ƒ  t j g  | d ƒ Wd  QXq Wd  S(   Niÿÿÿÿi   i    (   iÿÿÿÿi   (   R   R!   R   RÝ   (   R   R<   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_invalid_rQ  s    c         C   s-   |  j  t ƒ  t j d d d ƒ Wd  QXd  S(   NRÜ   i   iÜÿÿÿ(   R   R­   R   RÝ   (   R   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_invalid_indexV  s    (   R   R   RH   Rá   Râ   Rã   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRÛ   D  s   			t   PrependTestsc           B   s   e  Z d  „  Z d „  Z RS(   c         C   sJ   d } t  d ƒ } t t j | | ƒ ƒ } t d ƒ } |  j | | ƒ d  S(   NRe   t   bcdefgRÜ   (   t   iterR   R   t   prependR
   (   R   t   valuet   iteratorRà   Rß   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRH   \  s
    c         C   sN   d } t  d ƒ } t t j | | ƒ ƒ } d t d ƒ } |  j | | ƒ d  S(   Nt   abt   cdefg(   Rê   (   Ræ   R&   R   Rç   R
   (   R   Rè   Ré   Rà   Rß   (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   test_multiplec  s
    (   R   R   RH   Rì   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyRä   [  s   	('   t   doctestR    t   unittestR   t	   itertoolsR   t	   six.movesR   t   more_itertoolsR   R   R	   R   R$   R,   R9   RB   RK   RY   R`   Rd   Rl   Rn   Rr   Ry   R}   R„   RŠ   R’   R•   R£   Rª   R´   R½   RÈ   RÒ   R×   RÛ   Rä   (    (    (    s@   lib/python2.7/site-packages/more_itertools/tests/test_recipes.pyt   <module>   sB   	
+'