<s> import functools <EOL> import sys <EOL> import unittest <EOL> from test import test_support <EOL> from weakref import proxy <EOL> import pickle <EOL> @ staticmethod <EOL> def PythonPartial ( func , * args , ** keywords ) : <EOL> '<STR_LIT>' <EOL> def newfunc ( * fargs , ** fkeywords ) : <EOL> newkeywords = keywords . copy ( ) <EOL> newkeywords . update ( fkeywords ) <EOL> return func ( * ( args + fargs ) , ** newkeywords ) <EOL> newfunc . func = func <EOL> newfunc . args = args <EOL> newfunc . keywords = keywords <EOL> return newfunc <EOL> def capture ( * args , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return args , kw <EOL> def signature ( part ) : <EOL> """<STR_LIT>""" <EOL> return ( part . func , part . args , part . keywords , part . __dict__ ) <EOL> class TestPartial ( unittest . TestCase ) : <EOL> thetype = functools . partial <EOL> def test_basic_examples ( self ) : <EOL> p = self . thetype ( capture , <NUM_LIT:1> , <NUM_LIT:2> , a = <NUM_LIT:10> , b = <NUM_LIT:20> ) <EOL> self . assertEqual ( p ( <NUM_LIT:3> , <NUM_LIT:4> , b = <NUM_LIT:30> , c = <NUM_LIT> ) , <EOL> ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) , dict ( a = <NUM_LIT:10> , b = <NUM_LIT:30> , c = <NUM_LIT> ) ) ) <EOL> p = self . thetype ( map , lambda x : x * <NUM_LIT:10> ) <EOL> self . assertEqual ( p ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) , [ <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT:30> , <NUM_LIT> ] ) <EOL> def test_attributes ( self ) : <EOL> p = self . thetype ( capture , <NUM_LIT:1> , <NUM_LIT:2> , a = <NUM_LIT:10> , b = <NUM_LIT:20> ) <EOL> self . assertEqual ( p . func , capture ) <EOL> self . assertEqual ( p . args , ( <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> self . assertEqual ( p . keywords , dict ( a = <NUM_LIT:10> , b = <NUM_LIT:20> ) ) <EOL> self . assertRaises ( TypeError , setattr , p , '<STR_LIT>' , map ) <EOL> self . assertRaises ( TypeError , setattr , p , '<STR_LIT:args>' , ( <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> self . assertRaises ( TypeError , setattr , p , '<STR_LIT>' , dict ( a = <NUM_LIT:1> , b = <NUM_LIT:2> ) ) <EOL> p = self . thetype ( hex ) <EOL> try : <EOL> del p . __dict__ <EOL> except TypeError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_argument_checking ( self ) : <EOL> self . assertRaises ( TypeError , self . thetype ) <EOL> try : <EOL> self . thetype ( <NUM_LIT:2> ) ( ) <EOL> except TypeError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_protection_of_callers_dict_argument ( self ) : <EOL> def func ( a = <NUM_LIT:10> , b = <NUM_LIT:20> ) : <EOL> return a <EOL> d = { '<STR_LIT:a>' : <NUM_LIT:3> } <EOL> p = self . thetype ( func , a = <NUM_LIT:5> ) <EOL> self . assertEqual ( p ( ** d ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( d , { '<STR_LIT:a>' : <NUM_LIT:3> } ) <EOL> p ( b = <NUM_LIT:7> ) <EOL> self . assertEqual ( d , { '<STR_LIT:a>' : <NUM_LIT:3> } ) <EOL> def test_arg_combinations ( self ) : <EOL> p = self . thetype ( capture ) <EOL> self . assertEqual ( p ( ) , ( ( ) , { } ) ) <EOL> self . assertEqual ( p ( <NUM_LIT:1> , <NUM_LIT:2> ) , ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , { } ) ) <EOL> p = self . thetype ( capture , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> self . assertEqual ( p ( ) , ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , { } ) ) <EOL> self . assertEqual ( p ( <NUM_LIT:3> , <NUM_LIT:4> ) , ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) , { } ) ) <EOL> def test_kw_combinations ( self ) : <EOL> p = self . thetype ( capture ) <EOL> self . assertEqual ( p ( ) , ( ( ) , { } ) ) <EOL> self . assertEqual ( p ( a = <NUM_LIT:1> ) , ( ( ) , { '<STR_LIT:a>' : <NUM_LIT:1> } ) ) <EOL> p = self . thetype ( capture , a = <NUM_LIT:1> ) <EOL> self . assertEqual ( p ( ) , ( ( ) , { '<STR_LIT:a>' : <NUM_LIT:1> } ) ) <EOL> self . assertEqual ( p ( b = <NUM_LIT:2> ) , ( ( ) , { '<STR_LIT:a>' : <NUM_LIT:1> , '<STR_LIT:b>' : <NUM_LIT:2> } ) ) <EOL> self . assertEqual ( p ( a = <NUM_LIT:3> , b = <NUM_LIT:2> ) , ( ( ) , { '<STR_LIT:a>' : <NUM_LIT:3> , '<STR_LIT:b>' : <NUM_LIT:2> } ) ) <EOL> def test_positional ( self ) : <EOL> for args in [ ( ) , ( <NUM_LIT:0> , ) , ( <NUM_LIT:0> , <NUM_LIT:1> ) , ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ) , ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ] : <EOL> p = self . thetype ( capture , * args ) <EOL> expected = args + ( '<STR_LIT:x>' , ) <EOL> got , empty = p ( '<STR_LIT:x>' ) <EOL> self . assertTrue ( expected == got and empty == { } ) <EOL> def test_keyword ( self ) : <EOL> for a in [ '<STR_LIT:a>' , <NUM_LIT:0> , None , <NUM_LIT> ] : <EOL> p = self . thetype ( capture , a = a ) <EOL> expected = { '<STR_LIT:a>' : a , '<STR_LIT:x>' : None } <EOL> empty , got = p ( x = None ) <EOL> self . assertTrue ( expected == got and empty == ( ) ) <EOL> def test_no_side_effects ( self ) : <EOL> p = self . thetype ( capture , <NUM_LIT:0> , a = <NUM_LIT:1> ) <EOL> args1 , kw1 = p ( <NUM_LIT:1> , b = <NUM_LIT:2> ) <EOL> self . assertTrue ( args1 == ( <NUM_LIT:0> , <NUM_LIT:1> ) and kw1 == { '<STR_LIT:a>' : <NUM_LIT:1> , '<STR_LIT:b>' : <NUM_LIT:2> } ) <EOL> args2 , kw2 = p ( ) <EOL> self . assertTrue ( args2 == ( <NUM_LIT:0> , ) and kw2 == { '<STR_LIT:a>' : <NUM_LIT:1> } ) <EOL> def test_error_propagation ( self ) : <EOL> def f ( x , y ) : <EOL> x // y <EOL> self . assertRaises ( ZeroDivisionError , self . thetype ( f , <NUM_LIT:1> , <NUM_LIT:0> ) ) <EOL> self . assertRaises ( ZeroDivisionError , self . thetype ( f , <NUM_LIT:1> ) , <NUM_LIT:0> ) <EOL> self . assertRaises ( ZeroDivisionError , self . thetype ( f ) , <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> self . assertRaises ( ZeroDivisionError , self . thetype ( f , y = <NUM_LIT:0> ) , <NUM_LIT:1> ) <EOL> def test_weakref ( self ) : <EOL> f = self . thetype ( int , base = <NUM_LIT:16> ) <EOL> p = proxy ( f ) <EOL> self . assertEqual ( f . func , p . func ) <EOL> f = None <EOL> self . assertRaises ( ReferenceError , getattr , p , '<STR_LIT>' ) <EOL> def test_with_bound_and_unbound_methods ( self ) : <EOL> data = map ( str , range ( <NUM_LIT:10> ) ) <EOL> join = self . thetype ( str . join , '<STR_LIT>' ) <EOL> self . assertEqual ( join ( data ) , '<STR_LIT>' ) <EOL> join = self . thetype ( '<STR_LIT>' . join ) <EOL> self . assertEqual ( join ( data ) , '<STR_LIT>' ) <EOL> def test_pickle ( self ) : <EOL> f = self . thetype ( signature , '<STR_LIT>' , bar = True ) <EOL> f . add_something_to__dict__ = True <EOL> for proto in range ( pickle . HIGHEST_PROTOCOL + <NUM_LIT:1> ) : <EOL> f_copy = pickle . loads ( pickle . dumps ( f , proto ) ) <EOL> self . assertEqual ( signature ( f ) , signature ( f_copy ) ) <EOL> def test_setstate_refcount ( self ) : <EOL> class BadSequence : <EOL> def __len__ ( self ) : <EOL> return <NUM_LIT:4> <EOL> def __getitem__ ( self , key ) : <EOL> if key == <NUM_LIT:0> : <EOL> return max <EOL> elif key == <NUM_LIT:1> : <EOL> return tuple ( range ( <NUM_LIT> ) ) <EOL> elif key in ( <NUM_LIT:2> , <NUM_LIT:3> ) : <EOL> return { } <EOL> raise IndexError <EOL> f = self . thetype ( object ) <EOL> self . assertRaises ( SystemError , f . __setstate__ , BadSequence ( ) ) <EOL> class PartialSubclass ( functools . partial ) : <EOL> pass <EOL> class TestPartialSubclass ( TestPartial ) : <EOL> thetype = PartialSubclass <EOL> class TestPythonPartial ( TestPartial ) : <EOL> thetype = PythonPartial <EOL> test_pickle = test_setstate_refcount = None <EOL> test_attributes = None <EOL> class TestUpdateWrapper ( unittest . TestCase ) : <EOL> def check_wrapper ( self , wrapper , wrapped , <EOL> assigned = functools . WRAPPER_ASSIGNMENTS , <EOL> updated = functools . WRAPPER_UPDATES ) : <EOL> for name in assigned : <EOL> self . assertTrue ( getattr ( wrapper , name ) is getattr ( wrapped , name ) ) <EOL> for name in updated : <EOL> wrapper_attr = getattr ( wrapper , name ) <EOL> wrapped_attr = getattr ( wrapped , name ) <EOL> for key in wrapped_attr : <EOL> self . assertTrue ( wrapped_attr [ key ] is wrapper_attr [ key ] ) <EOL> def _default_update ( self ) : <EOL> def f ( ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> f . attr = '<STR_LIT>' <EOL> def wrapper ( ) : <EOL> pass <EOL> functools . update_wrapper ( wrapper , f ) <EOL> return wrapper , f <EOL> def test_default_update ( self ) : <EOL> wrapper , f = self . _default_update ( ) <EOL> self . check_wrapper ( wrapper , f ) <EOL> self . assertEqual ( wrapper . __name__ , '<STR_LIT:f>' ) <EOL> self . assertEqual ( wrapper . attr , '<STR_LIT>' ) <EOL> @ unittest . skipIf ( sys . flags . optimize >= <NUM_LIT:2> , <EOL> "<STR_LIT>" ) <EOL> def test_default_update_doc ( self ) : <EOL> wrapper , f = self . _default_update ( ) <EOL> self . assertEqual ( wrapper . __doc__ , '<STR_LIT>' ) <EOL> def test_no_update ( self ) : <EOL> def f ( ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> f . attr = '<STR_LIT>' <EOL> def wrapper ( ) : <EOL> pass <EOL> functools . update_wrapper ( wrapper , f , ( ) , ( ) ) <EOL> self . check_wrapper ( wrapper , f , ( ) , ( ) ) <EOL> self . assertEqual ( wrapper . __name__ , '<STR_LIT>' ) <EOL> self . assertEqual ( wrapper . __doc__ , None ) <EOL> self . assertFalse ( hasattr ( wrapper , '<STR_LIT>' ) ) <EOL> def test_selective_update ( self ) : <EOL> def f ( ) : <EOL> pass <EOL> f . attr = '<STR_LIT>' <EOL> f . dict_attr = dict ( a = <NUM_LIT:1> , b = <NUM_LIT:2> , c = <NUM_LIT:3> ) <EOL> def wrapper ( ) : <EOL> pass <EOL> wrapper . dict_attr = { } <EOL> assign = ( '<STR_LIT>' , ) <EOL> update = ( '<STR_LIT>' , ) <EOL> functools . update_wrapper ( wrapper , f , assign , update ) <EOL> self . check_wrapper ( wrapper , f , assign , update ) <EOL> self . assertEqual ( wrapper . __name__ , '<STR_LIT>' ) <EOL> self . assertEqual ( wrapper . __doc__ , None ) <EOL> self . assertEqual ( wrapper . attr , '<STR_LIT>' ) <EOL> self . assertEqual ( wrapper . dict_attr , f . dict_attr ) <EOL> @ test_support . requires_docstrings <EOL> def test_builtin_update ( self ) : <EOL> def wrapper ( ) : <EOL> pass <EOL> functools . update_wrapper ( wrapper , max ) <EOL> self . assertEqual ( wrapper . __name__ , '<STR_LIT>' ) <EOL> self . assertTrue ( wrapper . __doc__ . startswith ( '<STR_LIT>' ) ) <EOL> class TestWraps ( TestUpdateWrapper ) : <EOL> def _default_update ( self ) : <EOL> def f ( ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> f . attr = '<STR_LIT>' <EOL> @ functools . wraps ( f ) <EOL> def wrapper ( ) : <EOL> pass <EOL> self . check_wrapper ( wrapper , f ) <EOL> return wrapper <EOL> def test_default_update ( self ) : <EOL> wrapper = self . _default_update ( ) <EOL> self . assertEqual ( wrapper . __name__ , '<STR_LIT:f>' ) <EOL> self . assertEqual ( wrapper . attr , '<STR_LIT>' ) <EOL> @ unittest . skipIf ( sys . flags . optimize >= <NUM_LIT:2> , <EOL> "<STR_LIT>" ) <EOL> def test_default_update_doc ( self ) : <EOL> wrapper = self . _default_update ( ) <EOL> self . assertEqual ( wrapper . __doc__ , '<STR_LIT>' ) <EOL> def test_no_update ( self ) : <EOL> def f ( ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> f . attr = '<STR_LIT>' <EOL> @ functools . wraps ( f , ( ) , ( ) ) <EOL> def wrapper ( ) : <EOL> pass <EOL> self . check_wrapper ( wrapper , f , ( ) , ( ) ) <EOL> self . assertEqual ( wrapper . __name__ , '<STR_LIT>' ) <EOL> self . assertEqual ( wrapper . __doc__ , None ) <EOL> self . assertFalse ( hasattr ( wrapper , '<STR_LIT>' ) ) <EOL> def test_selective_update ( self ) : <EOL> def f ( ) : <EOL> pass <EOL> f . attr = '<STR_LIT>' <EOL> f . dict_attr = dict ( a = <NUM_LIT:1> , b = <NUM_LIT:2> , c = <NUM_LIT:3> ) <EOL> def add_dict_attr ( f ) : <EOL> f . dict_attr = { } <EOL> return f <EOL> assign = ( '<STR_LIT>' , ) <EOL> update = ( '<STR_LIT>' , ) <EOL> @ functools . wraps ( f , assign , update ) <EOL> @ add_dict_attr <EOL> def wrapper ( ) : <EOL> pass <EOL> self . check_wrapper ( wrapper , f , assign , update ) <EOL> self . assertEqual ( wrapper . __name__ , '<STR_LIT>' ) <EOL> self . assertEqual ( wrapper . __doc__ , None ) <EOL> self . assertEqual ( wrapper . attr , '<STR_LIT>' ) <EOL> self . assertEqual ( wrapper . dict_attr , f . dict_attr ) <EOL> class TestReduce ( unittest . TestCase ) : <EOL> def test_reduce ( self ) : <EOL> class Squares : <EOL> def __init__ ( self , max ) : <EOL> self . max = max <EOL> self . sofar = [ ] <EOL> def __len__ ( self ) : return len ( self . sofar ) <EOL> def __getitem__ ( self , i ) : <EOL> if not <NUM_LIT:0> <= i < self . max : raise IndexError <EOL> n = len ( self . sofar ) <EOL> while n <= i : <EOL> self . sofar . append ( n * n ) <EOL> n += <NUM_LIT:1> <EOL> return self . sofar [ i ] <EOL> reduce = functools . reduce <EOL> self . assertEqual ( reduce ( lambda x , y : x + y , [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] , '<STR_LIT>' ) , '<STR_LIT:abc>' ) <EOL> self . assertEqual ( <EOL> reduce ( lambda x , y : x + y , [ [ '<STR_LIT:a>' , '<STR_LIT:c>' ] , [ ] , [ '<STR_LIT:d>' , '<STR_LIT:w>' ] ] , [ ] ) , <EOL> [ '<STR_LIT:a>' , '<STR_LIT:c>' , '<STR_LIT:d>' , '<STR_LIT:w>' ] <EOL> ) <EOL> self . assertEqual ( reduce ( lambda x , y : x * y , range ( <NUM_LIT:2> , <NUM_LIT:8> ) , <NUM_LIT:1> ) , <NUM_LIT> ) <EOL> self . assertEqual ( <EOL> reduce ( lambda x , y : x * y , range ( <NUM_LIT:2> , <NUM_LIT> ) , <NUM_LIT:1> L ) , <EOL> <NUM_LIT> L <EOL> ) <EOL> self . assertEqual ( reduce ( lambda x , y : x + y , Squares ( <NUM_LIT:10> ) ) , <NUM_LIT> ) <EOL> self . assertEqual ( reduce ( lambda x , y : x + y , Squares ( <NUM_LIT:10> ) , <NUM_LIT:0> ) , <NUM_LIT> ) <EOL> self . assertEqual ( reduce ( lambda x , y : x + y , Squares ( <NUM_LIT:0> ) , <NUM_LIT:0> ) , <NUM_LIT:0> ) <EOL> self . assertRaises ( TypeError , reduce ) <EOL> self . assertRaises ( TypeError , reduce , <NUM_LIT> , <NUM_LIT> ) <EOL> self . assertRaises ( TypeError , reduce , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . assertEqual ( reduce ( <NUM_LIT> , "<STR_LIT:1>" ) , "<STR_LIT:1>" ) <EOL> self . assertEqual ( reduce ( <NUM_LIT> , "<STR_LIT>" , "<STR_LIT:1>" ) , "<STR_LIT:1>" ) <EOL> self . assertRaises ( TypeError , reduce , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> class TestCmpToKey ( unittest . TestCase ) : <EOL> def test_cmp_to_key ( self ) : <EOL> def mycmp ( x , y ) : <EOL> return y - x <EOL> self . assertEqual ( sorted ( range ( <NUM_LIT:5> ) , key = functools . cmp_to_key ( mycmp ) ) , <EOL> [ <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> ] ) <EOL> def test_hash ( self ) : <EOL> def mycmp ( x , y ) : <EOL> return y - x <EOL> key = functools . cmp_to_key ( mycmp ) <EOL> k = key ( <NUM_LIT:10> ) <EOL> self . assertRaises ( TypeError , hash ( k ) ) <EOL> class TestTotalOrdering ( unittest . TestCase ) : <EOL> def test_total_ordering_lt ( self ) : <EOL> @ functools . total_ordering <EOL> class A : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __lt__ ( self , other ) : <EOL> return self . value < other . value <EOL> def __eq__ ( self , other ) : <EOL> return self . value == other . value <EOL> self . assertTrue ( A ( <NUM_LIT:1> ) < A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) > A ( <NUM_LIT:1> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:1> ) <= A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) >= A ( <NUM_LIT:1> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) <= A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) >= A ( <NUM_LIT:2> ) ) <EOL> def test_total_ordering_le ( self ) : <EOL> @ functools . total_ordering <EOL> class A : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __le__ ( self , other ) : <EOL> return self . value <= other . value <EOL> def __eq__ ( self , other ) : <EOL> return self . value == other . value <EOL> self . assertTrue ( A ( <NUM_LIT:1> ) < A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) > A ( <NUM_LIT:1> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:1> ) <= A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) >= A ( <NUM_LIT:1> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) <= A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) >= A ( <NUM_LIT:2> ) ) <EOL> def test_total_ordering_gt ( self ) : <EOL> @ functools . total_ordering <EOL> class A : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __gt__ ( self , other ) : <EOL> return self . value > other . value <EOL> def __eq__ ( self , other ) : <EOL> return self . value == other . value <EOL> self . assertTrue ( A ( <NUM_LIT:1> ) < A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) > A ( <NUM_LIT:1> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:1> ) <= A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) >= A ( <NUM_LIT:1> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) <= A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) >= A ( <NUM_LIT:2> ) ) <EOL> def test_total_ordering_ge ( self ) : <EOL> @ functools . total_ordering <EOL> class A : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __ge__ ( self , other ) : <EOL> return self . value >= other . value <EOL> def __eq__ ( self , other ) : <EOL> return self . value == other . value <EOL> self . assertTrue ( A ( <NUM_LIT:1> ) < A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) > A ( <NUM_LIT:1> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:1> ) <= A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) >= A ( <NUM_LIT:1> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) <= A ( <NUM_LIT:2> ) ) <EOL> self . assertTrue ( A ( <NUM_LIT:2> ) >= A ( <NUM_LIT:2> ) ) <EOL> def test_total_ordering_no_overwrite ( self ) : <EOL> @ functools . total_ordering <EOL> class A ( str ) : <EOL> pass <EOL> self . assertTrue ( A ( "<STR_LIT:a>" ) < A ( "<STR_LIT:b>" ) ) <EOL> self . assertTrue ( A ( "<STR_LIT:b>" ) > A ( "<STR_LIT:a>" ) ) <EOL> self . assertTrue ( A ( "<STR_LIT:a>" ) <= A ( "<STR_LIT:b>" ) ) <EOL> self . assertTrue ( A ( "<STR_LIT:b>" ) >= A ( "<STR_LIT:a>" ) ) <EOL> self . assertTrue ( A ( "<STR_LIT:b>" ) <= A ( "<STR_LIT:b>" ) ) <EOL> self . assertTrue ( A ( "<STR_LIT:b>" ) >= A ( "<STR_LIT:b>" ) ) <EOL> def test_no_operations_defined ( self ) : <EOL> with self . assertRaises ( ValueError ) : <EOL> @ functools . total_ordering <EOL> class A : <EOL> pass <EOL> def test_bug_10042 ( self ) : <EOL> @ functools . total_ordering <EOL> class TestTO : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __eq__ ( self , other ) : <EOL> if isinstance ( other , TestTO ) : <EOL> return self . value == other . value <EOL> return False <EOL> def __lt__ ( self , other ) : <EOL> if isinstance ( other , TestTO ) : <EOL> return self . value < other . value <EOL> raise TypeError <EOL> with self . assertRaises ( TypeError ) : <EOL> TestTO ( <NUM_LIT:8> ) <= ( ) <EOL> def test_main ( verbose = None ) : <EOL> test_classes = ( <EOL> TestPartial , <EOL> TestPartialSubclass , <EOL> TestPythonPartial , <EOL> TestUpdateWrapper , <EOL> TestTotalOrdering , <EOL> TestWraps , <EOL> TestReduce , <EOL> ) <EOL> test_support . run_unittest ( * test_classes ) <EOL> if verbose and hasattr ( sys , "<STR_LIT>" ) : <EOL> import gc <EOL> counts = [ None ] * <NUM_LIT:5> <EOL> for i in xrange ( len ( counts ) ) : <EOL> test_support . run_unittest ( * test_classes ) <EOL> gc . collect ( ) <EOL> counts [ i ] = sys . gettotalrefcount ( ) <EOL> print counts <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_main ( verbose = True ) </s>
