<s> from UnitTest import UnitTest <EOL> try : <EOL> builtin_value = builtin . value <EOL> except : <EOL> builtin_value = None <EOL> if False : <EOL> import builtin <EOL> import builtin <EOL> from imports . cls import CLS <EOL> from imports . cls1 import CLS as CLS1 <EOL> def other ( ** kwargs ) : <EOL> return kwargs <EOL> def foo ( _some , _long , _list , _of , _arguments ) : <EOL> _additional = <NUM_LIT:5> <EOL> return other ( ** locals ( ) ) <EOL> class ColourThing ( object ) : <EOL> def rgb ( ) : <EOL> def fset ( self , rgb ) : <EOL> self . r , self . g , self . b = rgb <EOL> def fget ( self ) : <EOL> return ( self . r , self . g , self . b ) <EOL> return property ( ** locals ( ) ) <EOL> class C ( object ) : <EOL> @ property <EOL> def x ( self ) : <EOL> return [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> class Foo : <EOL> pass <EOL> class LocalsTest : <EOL> def __init__ ( self ) : <EOL> pass <EOL> def testargs ( self , test1 , test2 ) : <EOL> return locals ( ) <EOL> def testkwargs ( self , test1 = None , test2 = None ) : <EOL> return locals ( ) <EOL> class BuiltinTest ( UnitTest ) : <EOL> def testMinMax ( self ) : <EOL> self . assertEqual ( max ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) , <NUM_LIT:4> ) <EOL> self . assertEqual ( min ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( max ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) , <NUM_LIT:4> ) <EOL> self . assertEqual ( min ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( max ( [ <NUM_LIT:5> , <NUM_LIT:3> , <NUM_LIT:4> ] , [ <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> ] ) == [ <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> ] , "<STR_LIT>" ) <EOL> self . assertTrue ( min ( [ <NUM_LIT:5> , <NUM_LIT:3> , <NUM_LIT:4> ] , [ <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> ] ) == [ <NUM_LIT:5> , <NUM_LIT:3> , <NUM_LIT:4> ] , "<STR_LIT>" ) <EOL> def testIterProperty ( self ) : <EOL> o = C ( ) <EOL> tst = [ ] <EOL> for y in iter ( o . x ) : <EOL> tst . append ( y ) <EOL> self . assertTrue ( tst , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> tst = [ ] <EOL> try : <EOL> for y in o . x : <EOL> tst . append ( y ) <EOL> self . assertTrue ( tst , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def testInt ( self ) : <EOL> self . assertEqual ( int ( "<STR_LIT:5>" ) , <NUM_LIT:5> ) <EOL> self . assertEqual ( int ( "<STR_LIT>" ) , <NUM_LIT:9> ) <EOL> self . assertEqual ( <NUM_LIT:6> , <NUM_LIT:6> ) <EOL> self . assertEqual ( int ( "<STR_LIT:0>" ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( int ( <NUM_LIT:0> ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( int ( "<STR_LIT>" ) , - <NUM_LIT:1> ) <EOL> self . assertEqual ( int ( "<STR_LIT>" ) , - <NUM_LIT:2> ) <EOL> self . assertEqual ( int ( "<STR_LIT>" ) , - <NUM_LIT:3> ) <EOL> try : <EOL> int ( '<STR_LIT>' ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except ValueError , e : <EOL> self . assertEqual ( e [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> try : <EOL> int ( '<STR_LIT:U+0020>' ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except ValueError , e : <EOL> self . assertEqual ( e [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> try : <EOL> int ( '<STR_LIT>' ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except ValueError , e : <EOL> self . assertEqual ( e [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> try : <EOL> int ( <NUM_LIT:1> , <NUM_LIT:10> ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except TypeError , e : <EOL> self . assertEqual ( e [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> try : <EOL> int ( '<STR_LIT>' ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except ValueError , e : <EOL> self . assertEqual ( e [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> def testFloat ( self ) : <EOL> self . assertEqual ( float ( "<STR_LIT>" ) , <NUM_LIT> ) <EOL> self . assertEqual ( float ( "<STR_LIT>" ) , <NUM_LIT:9> ) <EOL> self . assertEqual ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . assertEqual ( float ( "<STR_LIT:0>" ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( float ( <NUM_LIT:0> ) , <NUM_LIT:0> ) <EOL> try : <EOL> float ( '<STR_LIT>' ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except ValueError , e : <EOL> self . assertEqual ( e [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> try : <EOL> float ( '<STR_LIT>' ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except ValueError , e : <EOL> self . assertEqual ( e [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> try : <EOL> float ( '<STR_LIT:U+0020>' ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except ValueError , e : <EOL> self . assertEqual ( e [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( <NUM_LIT:1.0> , float ) , "<STR_LIT>" ) <EOL> def testOrdChr ( self ) : <EOL> for i in range ( <NUM_LIT> ) : <EOL> self . assertEqual ( ord ( chr ( i ) ) , i ) <EOL> def testMod ( self ) : <EOL> self . assertEqual ( <NUM_LIT:12> % <NUM_LIT:5> , <NUM_LIT:2> ) <EOL> self . assertEqual ( - <NUM_LIT> % <NUM_LIT:1> , <NUM_LIT> , "<STR_LIT>" ) <EOL> self . assertEqual ( - <NUM_LIT> % <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> self . assertEqual ( - <NUM_LIT:1> % <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> self . assertEqual ( - <NUM_LIT:1> % - <NUM_LIT:2> , - <NUM_LIT:1> ) <EOL> self . assertEqual ( - <NUM_LIT:1> % <NUM_LIT:3> L , <NUM_LIT:2> L ) <EOL> self . assertEqual ( - <NUM_LIT:2> % - <NUM_LIT:3> L , - <NUM_LIT:2> L ) <EOL> self . assertEqual ( - <NUM_LIT:1> L % <NUM_LIT:4> , <NUM_LIT:3> L ) <EOL> self . assertEqual ( - <NUM_LIT:3> L % - <NUM_LIT:4> , - <NUM_LIT:3> L ) <EOL> self . assertEqual ( - <NUM_LIT:1> L % <NUM_LIT:5> L , <NUM_LIT:4> L ) <EOL> self . assertEqual ( - <NUM_LIT:4> L % - <NUM_LIT:5> L , - <NUM_LIT:4> L ) <EOL> self . assertEqual ( - <NUM_LIT:1.0> % <NUM_LIT:6> , <NUM_LIT> ) <EOL> self . assertEqual ( - <NUM_LIT> % - <NUM_LIT:6> , - <NUM_LIT> ) <EOL> def testPower ( self ) : <EOL> self . assertEqual ( <NUM_LIT:3> ** <NUM_LIT:4> , <NUM_LIT> ) <EOL> def testPowerfunc ( self ) : <EOL> self . assertEqual ( pow ( <NUM_LIT:10> , <NUM_LIT:3> ) , <NUM_LIT:1000> ) <EOL> self . assertEqual ( pow ( <NUM_LIT:10> , <NUM_LIT:3> , <NUM_LIT:7> ) , <NUM_LIT:6> ) <EOL> def testHex ( self ) : <EOL> self . assertEqual ( hex ( <NUM_LIT> ) , '<STR_LIT>' ) <EOL> try : <EOL> h = hex ( <NUM_LIT> ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except TypeError , why : <EOL> self . assertEqual ( why . args [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> def testOct ( self ) : <EOL> self . assertEqual ( oct ( <NUM_LIT> ) , '<STR_LIT>' ) <EOL> try : <EOL> o = oct ( <NUM_LIT> ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except TypeError , why : <EOL> self . assertEqual ( str ( why ) , "<STR_LIT>" ) <EOL> def testRound ( self ) : <EOL> self . assertEqual ( round ( <NUM_LIT> ) , <NUM_LIT> ) <EOL> self . assertEqual ( round ( <NUM_LIT> , <NUM_LIT:3> ) , <NUM_LIT> ) <EOL> self . assertEqual ( round ( - <NUM_LIT> ) , - <NUM_LIT> ) <EOL> self . assertEqual ( round ( - <NUM_LIT> , <NUM_LIT:3> ) , - <NUM_LIT> ) <EOL> self . assertEqual ( round ( <NUM_LIT> ) , <NUM_LIT> ) <EOL> self . assertEqual ( round ( <NUM_LIT> , <NUM_LIT:3> ) , <NUM_LIT> ) <EOL> self . assertEqual ( round ( - <NUM_LIT> ) , - <NUM_LIT> ) <EOL> self . assertEqual ( round ( - <NUM_LIT> , <NUM_LIT:3> ) , - <NUM_LIT> ) <EOL> def testDivmod ( self ) : <EOL> test_set = [ ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:2> ) , <EOL> ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> ) , <EOL> ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <EOL> ] <EOL> for x , y , p , q in test_set : <EOL> d = divmod ( x , y ) <EOL> self . assertEqual ( d [ <NUM_LIT:0> ] , p ) <EOL> self . assertEqual ( abs ( d [ <NUM_LIT:1> ] - q ) < <NUM_LIT> , True ) <EOL> def testFloorDiv ( self ) : <EOL> self . assertEqual ( <NUM_LIT:1> , <NUM_LIT:4> // <NUM_LIT:3> ) <EOL> self . assertEqual ( <NUM_LIT:1> , <NUM_LIT:5> // <NUM_LIT:3> ) <EOL> self . assertEqual ( <NUM_LIT:2> , <NUM_LIT:6> // <NUM_LIT:3> ) <EOL> def testAll ( self ) : <EOL> self . assertEqual ( all ( [ True , <NUM_LIT:1> , '<STR_LIT:a>' ] ) , True ) <EOL> self . assertEqual ( all ( [ True , <NUM_LIT:1> , None , '<STR_LIT:a>' ] ) , False ) <EOL> self . assertEqual ( all ( [ True , <NUM_LIT:1> , '<STR_LIT>' , '<STR_LIT:a>' ] ) , False ) <EOL> self . assertEqual ( all ( [ True , <NUM_LIT:1> , False , '<STR_LIT:a>' ] ) , False ) <EOL> def testAny ( self ) : <EOL> self . assertEqual ( any ( [ True , <NUM_LIT:1> , '<STR_LIT:a>' ] ) , True ) <EOL> self . assertEqual ( any ( [ True , <NUM_LIT:1> , None , '<STR_LIT:a>' ] ) , True ) <EOL> self . assertEqual ( any ( [ True , <NUM_LIT:1> , '<STR_LIT>' , '<STR_LIT:a>' ] ) , True ) <EOL> self . assertEqual ( any ( [ True , <NUM_LIT:1> , False , '<STR_LIT:a>' ] ) , True ) <EOL> self . assertEqual ( any ( [ False , '<STR_LIT>' , None ] ) , False ) <EOL> def testRepr ( self ) : <EOL> l1 = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> l2 = [ "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:c>" ] <EOL> t1 = ( <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ) <EOL> t2 = ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> d1 = { '<STR_LIT:a>' : <NUM_LIT:1> , "<STR_LIT:b>" : "<STR_LIT:B>" } <EOL> d2 = { <NUM_LIT:1> : l1 , <NUM_LIT:2> : l2 , <NUM_LIT:3> : t1 , <NUM_LIT:4> : t2 , <NUM_LIT:5> : d1 } <EOL> i1 = <NUM_LIT> <EOL> f1 = <NUM_LIT> <EOL> self . assertEqual ( repr ( l1 ) , '<STR_LIT>' ) <EOL> self . assertEqual ( l1 . __repr__ ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( repr ( l2 ) , "<STR_LIT>" ) <EOL> self . assertEqual ( repr ( t1 ) , '<STR_LIT>' ) <EOL> self . assertEqual ( repr ( t2 ) , "<STR_LIT>" ) <EOL> self . assertEqual ( repr ( d1 ) , "<STR_LIT>" ) <EOL> self . assertEqual ( repr ( d2 ) , "<STR_LIT>" ) <EOL> self . assertEqual ( d2 . __repr__ ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( repr ( i1 ) , '<STR_LIT>' ) <EOL> self . assertEqual ( i1 . __repr__ ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( repr ( f1 ) , '<STR_LIT>' ) <EOL> self . assertEqual ( f1 . __repr__ ( ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( ` l1 ` , '<STR_LIT>' ) <EOL> def testIsInstance ( self ) : <EOL> s = '<STR_LIT:hello>' <EOL> self . assertTrue ( isinstance ( s , str ) , "<STR_LIT>" ) <EOL> self . assertFalse ( isinstance ( s , int ) , "<STR_LIT>" ) <EOL> s = <NUM_LIT:1> <EOL> self . assertFalse ( isinstance ( s , str ) , "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( s , int ) , "<STR_LIT>" ) <EOL> self . assertFalse ( isinstance ( '<STR_LIT>' , list ) , "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( [ ] , list ) , "<STR_LIT>" ) <EOL> class Cls ( object ) : <EOL> pass <EOL> self . assertTrue ( isinstance ( Cls , type ) , "<STR_LIT>" ) <EOL> def testImport ( self ) : <EOL> self . assertEqual ( builtin_value , None , "<STR_LIT>" ) <EOL> try : <EOL> self . assertEqual ( builtin . value , builtin . get_value ( ) ) <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> from imports import overrideme <EOL> cls1 = CLS1 ( ) <EOL> self . assertTrue ( CLS is CLS1 , "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( cls1 , CLS ) , "<STR_LIT>" ) <EOL> self . assertEqual ( overrideme , "<STR_LIT>" ) <EOL> import imports . override <EOL> self . assertEqual ( overrideme , "<STR_LIT>" ) <EOL> from imports import overrideme <EOL> try : <EOL> self . assertTrue ( overrideme . overridden is True , "<STR_LIT>" ) <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> import imports <EOL> self . assertTrue ( CLS is imports . loccls . CLS , "<STR_LIT>" ) <EOL> self . assertTrue ( CLS is imports . upcls . CLS , "<STR_LIT>" ) <EOL> self . assertEqual ( imports . all_masked , False , "<STR_LIT>" ) <EOL> self . assertEqual ( imports . all_override , True , "<STR_LIT>" ) <EOL> self . assertEqual ( imports . all_import1 , <NUM_LIT:1> ) <EOL> self . assertEqual ( imports . all_import2 , <NUM_LIT:3> ) <EOL> self . assertEqual ( imports . all_import3 , <NUM_LIT:3> ) <EOL> def testBitOperations ( self ) : <EOL> self . assertEqual ( <NUM_LIT:1> << <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT:2> , "<STR_LIT>" ) <EOL> self . assertEqual ( ( <NUM_LIT:1> << <NUM_LIT:2> ) - <NUM_LIT:1> , <NUM_LIT:3> , "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:1> & <NUM_LIT:3> + <NUM_LIT:1> , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> self . assertEqual ( ( <NUM_LIT:1> & <NUM_LIT:3> ) + <NUM_LIT:1> , <NUM_LIT:2> , "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:4> >> <NUM_LIT:2> , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . assertEqual ( - <NUM_LIT:4> >> <NUM_LIT:2> , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> def testLocals ( self ) : <EOL> v1 = <NUM_LIT:1> <EOL> v2 = <NUM_LIT:2> <EOL> local_vars = locals ( ) <EOL> self . assertEqual ( len ( local_vars ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( local_vars [ '<STR_LIT>' ] , <NUM_LIT:1> ) <EOL> def fn1 ( ) : <EOL> a = <NUM_LIT:1> <EOL> def fn2 ( ) : <EOL> b = <NUM_LIT:1> <EOL> c = locals ( ) <EOL> return c <EOL> return fn2 ( ) <EOL> local_vars = fn1 ( ) <EOL> self . assertEqual ( local_vars , { '<STR_LIT:b>' : <NUM_LIT:1> } ) <EOL> def fn2 ( ) : <EOL> lx = <NUM_LIT:3> <EOL> def g ( ) : <EOL> li = lx <EOL> return locals ( ) <EOL> return g ( ) <EOL> self . assertEqual ( fn2 ( ) , { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT>' : <NUM_LIT:3> } , "<STR_LIT>" ) <EOL> def fn3 ( ) : <EOL> lx = <NUM_LIT:3> <EOL> def g ( ) : <EOL> def lh ( ) : <EOL> li = lx <EOL> return locals ( ) <EOL> return locals ( ) , lh ( ) <EOL> return g ( ) <EOL> outer_locals , inner_locals = fn3 ( ) <EOL> self . assertEqual ( inner_locals , { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT>' : <NUM_LIT:3> } , "<STR_LIT>" ) <EOL> keys = outer_locals . keys ( ) <EOL> keys . sort ( ) <EOL> self . assertEqual ( keys , [ '<STR_LIT>' , '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> def fn4 ( x ) : <EOL> class X : <EOL> x = <NUM_LIT:12> <EOL> def fn4 ( self ) : <EOL> return x <EOL> locals ( ) <EOL> return X <EOL> self . assertEqual ( fn4 ( <NUM_LIT:1> ) . x , <NUM_LIT:12> ) <EOL> args = { '<STR_LIT>' : <NUM_LIT:5> , '<STR_LIT>' : '<STR_LIT:hello>' } <EOL> la = LocalsTest ( ) <EOL> argsreturn = la . testkwargs ( ** args ) <EOL> args [ '<STR_LIT>' ] = la <EOL> self . assertEqual ( args , argsreturn ) <EOL> del args [ '<STR_LIT>' ] <EOL> argsreturn = la . testargs ( ** args ) <EOL> args [ '<STR_LIT>' ] = la <EOL> self . assertEqual ( args , argsreturn ) <EOL> t = ColourThing ( ) <EOL> t . rgb = <NUM_LIT:1> <EOL> self . assertEqual ( t . rgb , <NUM_LIT:1> ) <EOL> args = foo ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> self . assertEqual ( args , { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:5> , <EOL> '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:4> } ) <EOL> def testIfExp ( self ) : <EOL> var = <NUM_LIT:1> if True else <NUM_LIT:0> <EOL> self . assertEqual ( var , <NUM_LIT:1> ) <EOL> var = <NUM_LIT:1> if False else <NUM_LIT:0> <EOL> self . assertEqual ( var , <NUM_LIT:0> ) <EOL> var = <NUM_LIT:1> if [ ] else <NUM_LIT:0> <EOL> self . assertEqual ( var , <NUM_LIT:0> ) <EOL> var = <NUM_LIT:1> if not [ ] else <NUM_LIT:0> <EOL> self . assertEqual ( var , <NUM_LIT:1> ) <EOL> def testRange ( self ) : <EOL> r = range ( <NUM_LIT:3> ) <EOL> self . assertEqual ( r , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> r = range ( <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> self . assertEqual ( r , [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> r = range ( <NUM_LIT:2> , <NUM_LIT:15> , <NUM_LIT:3> ) <EOL> self . assertEqual ( r , [ <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:8> , <NUM_LIT:11> , <NUM_LIT> ] ) <EOL> r = range ( <NUM_LIT:15> , <NUM_LIT:2> , - <NUM_LIT:3> ) <EOL> self . assertEqual ( r , [ <NUM_LIT:15> , <NUM_LIT:12> , <NUM_LIT:9> , <NUM_LIT:6> , <NUM_LIT:3> ] ) <EOL> r = range ( <NUM_LIT:15> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> self . assertEqual ( r , [ ] ) <EOL> r = range ( - <NUM_LIT:6> , - <NUM_LIT:2> , - <NUM_LIT:1> ) <EOL> self . assertEqual ( r , [ ] ) <EOL> def testXRange ( self ) : <EOL> r = [ i for i in xrange ( <NUM_LIT:3> ) ] <EOL> self . assertEqual ( r , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> r = [ i for i in xrange ( <NUM_LIT:2> , <NUM_LIT:5> ) ] <EOL> self . assertEqual ( r , [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> r = [ i for i in xrange ( <NUM_LIT:2> , <NUM_LIT:15> , <NUM_LIT:3> ) ] <EOL> self . assertEqual ( r , [ <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:8> , <NUM_LIT:11> , <NUM_LIT> ] ) <EOL> r = [ i for i in xrange ( <NUM_LIT:15> , <NUM_LIT:2> , - <NUM_LIT:3> ) ] <EOL> self . assertEqual ( r , [ <NUM_LIT:15> , <NUM_LIT:12> , <NUM_LIT:9> , <NUM_LIT:6> , <NUM_LIT:3> ] ) <EOL> r = [ i for i in xrange ( <NUM_LIT:15> , <NUM_LIT:2> , <NUM_LIT:3> ) ] <EOL> self . assertEqual ( r , [ ] ) <EOL> r = [ i for i in xrange ( - <NUM_LIT:6> , - <NUM_LIT:2> , - <NUM_LIT:1> ) ] <EOL> self . assertEqual ( r , [ ] ) <EOL> self . assertEqual ( str ( xrange ( <NUM_LIT:3> ) ) , "<STR_LIT>" ) <EOL> self . assertEqual ( str ( xrange ( <NUM_LIT:3> , <NUM_LIT:4> ) ) , "<STR_LIT>" ) <EOL> self . assertEqual ( str ( xrange ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ) ) , "<STR_LIT>" ) <EOL> self . assertEqual ( str ( xrange ( <NUM_LIT> , <NUM_LIT:3> , - <NUM_LIT:5> ) ) , "<STR_LIT>" ) <EOL> def testForLoop ( self ) : <EOL> n1 = <NUM_LIT:0> <EOL> n2 = <NUM_LIT:0> <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> n1 += i <EOL> for i in xrange ( <NUM_LIT:4> ) : <EOL> n2 += i <EOL> self . assertEqual ( n1 , <NUM_LIT> ) <EOL> self . assertEqual ( n2 , <NUM_LIT> ) <EOL> self . assertEqual ( i , <NUM_LIT:3> ) <EOL> try : <EOL> for i in xrange ( <NUM_LIT:4> ) : <EOL> raise StopIteration <EOL> self . fail ( "<STR_LIT>" ) <EOL> except StopIteration : <EOL> self . assertTrue ( True ) <EOL> self . assertEqual ( i , <NUM_LIT:0> ) <EOL> e = <NUM_LIT:0> <EOL> i = - <NUM_LIT:1> <EOL> for i in range ( <NUM_LIT:1> ) : <EOL> pass <EOL> else : <EOL> e = <NUM_LIT:1> <EOL> self . assertEqual ( i , <NUM_LIT:0> ) <EOL> self . assertEqual ( e , <NUM_LIT:1> ) <EOL> e = <NUM_LIT:0> <EOL> i = - <NUM_LIT:1> <EOL> for i in range ( <NUM_LIT:0> ) : <EOL> pass <EOL> else : <EOL> e = <NUM_LIT:1> <EOL> self . assertEqual ( i , - <NUM_LIT:1> ) <EOL> self . assertEqual ( e , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> e = <NUM_LIT:0> <EOL> i = - <NUM_LIT:1> <EOL> for i in range ( <NUM_LIT:1> ) : <EOL> e = <NUM_LIT:1> <EOL> break <EOL> else : <EOL> e = <NUM_LIT:2> <EOL> self . assertEqual ( i , <NUM_LIT:0> ) <EOL> self . assertEqual ( e , <NUM_LIT:1> ) <EOL> def testIter ( self ) : <EOL> class i : <EOL> def __init__ ( self ) : <EOL> self . idx = <NUM_LIT:0> <EOL> def __iter__ ( self ) : <EOL> return self <EOL> def next ( self ) : <EOL> self . idx += <NUM_LIT:1> <EOL> if self . idx == <NUM_LIT:5> : <EOL> raise StopIteration <EOL> return self . idx <EOL> res = [ ] <EOL> try : <EOL> for j in i ( ) : <EOL> res . append ( j ) <EOL> if len ( res ) > <NUM_LIT:5> : <EOL> self . fail ( "<STR_LIT>" ) <EOL> break <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> self . assertEqual ( res , range ( <NUM_LIT:1> , <NUM_LIT:5> ) ) <EOL> def testSorted ( self ) : <EOL> lst1 = range ( <NUM_LIT:10> ) <EOL> lst2 = range ( <NUM_LIT:10> ) <EOL> lst2 . reverse ( ) <EOL> self . assertTrue ( lst1 == sorted ( lst2 ) , "<STR_LIT>" ) <EOL> self . assertTrue ( lst1 == sorted ( xrange ( <NUM_LIT:10> ) ) , "<STR_LIT>" ) <EOL> self . assertTrue ( lst2 == sorted ( xrange ( <NUM_LIT:10> ) , reverse = True ) , "<STR_LIT>" ) <EOL> def testReversed ( self ) : <EOL> lst1 = range ( <NUM_LIT:10> ) <EOL> lst2 = range ( <NUM_LIT:10> ) <EOL> lst2 . reverse ( ) <EOL> tpl1 = tuple ( lst1 ) <EOL> self . assertTrue ( lst1 == list ( reversed ( lst2 ) ) , "<STR_LIT>" ) <EOL> self . assertTrue ( lst2 == list ( reversed ( xrange ( <NUM_LIT:10> ) ) ) , "<STR_LIT>" ) <EOL> self . assertTrue ( lst2 == list ( reversed ( tpl1 ) ) , "<STR_LIT>" ) <EOL> dict1 = { '<STR_LIT:a>' : '<STR_LIT:A>' , '<STR_LIT:b>' : '<STR_LIT:B>' } <EOL> self . assertRaises ( TypeError , reversed , dict1 ) <EOL> def testType ( self ) : <EOL> try : <EOL> self . assertTrue ( type ( object ) is type ) <EOL> except NotImplementedError , why : <EOL> self . fail ( "<STR_LIT>" + str ( why ) ) <EOL> self . assertTrue ( type ( [ ] ) is type ( [ ] ) ) <EOL> self . assertTrue ( type ( [ ] ) is list ) <EOL> try : <EOL> self . assertTrue ( type ( [ ] ) == list ) <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> self . assertTrue ( type ( "<STR_LIT>" ) is str , "<STR_LIT:str>" ) <EOL> self . assertTrue ( type ( True ) is bool , "<STR_LIT:bool>" ) <EOL> self . assertTrue ( type ( <NUM_LIT:1> ) is int , "<STR_LIT:int>" ) <EOL> self . assertTrue ( type ( <NUM_LIT:1> L ) is long , "<STR_LIT>" ) <EOL> self . assertTrue ( type ( <NUM_LIT> ) is float , "<STR_LIT>" ) <EOL> self . assertTrue ( type ( <NUM_LIT:1.0> ) is float , "<STR_LIT>" ) <EOL> def testIter ( self ) : <EOL> class G ( object ) : <EOL> def __getitem__ ( self , i ) : <EOL> if <NUM_LIT:0> <= i <= <NUM_LIT:4> : <EOL> return i <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> def fn ( ) : <EOL> for i in [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] : <EOL> yield i <EOL> lst = [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] <EOL> self . assertEqual ( lst , list ( iter ( lst ) ) , "<STR_LIT>" ) <EOL> g = G ( ) <EOL> self . assertEqual ( lst , list ( iter ( g ) ) , "<STR_LIT>" ) <EOL> self . assertEqual ( lst , list ( iter ( fn ( ) . next , <NUM_LIT:5> ) ) , "<STR_LIT>" ) <EOL> self . assertEqual ( [ <NUM_LIT:0> , <NUM_LIT:1> ] , list ( iter ( fn ( ) . next , <NUM_LIT:2> ) ) , "<STR_LIT>" ) <EOL> def testReduce ( self ) : <EOL> v = reduce ( lambda x , y : x + y , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> self . assertEqual ( v , <NUM_LIT:15> ) <EOL> def testZip ( self ) : <EOL> lst1 = [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> lst2 = [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> ] <EOL> dict1 = { '<STR_LIT:a>' : '<STR_LIT:A>' , '<STR_LIT:b>' : '<STR_LIT:B>' } <EOL> v = zip ( lst1 ) <EOL> self . assertEqual ( v , [ ( <NUM_LIT:0> , ) , ( <NUM_LIT:1> , ) , ( <NUM_LIT:2> , ) , ( <NUM_LIT:3> , ) ] ) <EOL> v = zip ( lst1 , lst2 ) <EOL> self . assertEqual ( v , [ ( <NUM_LIT:0> , <NUM_LIT:10> ) , ( <NUM_LIT:1> , <NUM_LIT:11> ) , ( <NUM_LIT:2> , <NUM_LIT:12> ) ] ) <EOL> v = zip ( dict1 ) <EOL> self . assertEqual ( v , [ ( '<STR_LIT:a>' , ) , ( '<STR_LIT:b>' , ) ] ) <EOL> v = zip ( lst1 , dict1 , lst2 ) <EOL> self . assertEqual ( v , [ ( <NUM_LIT:0> , '<STR_LIT:a>' , <NUM_LIT:10> ) , ( <NUM_LIT:1> , '<STR_LIT:b>' , <NUM_LIT:11> ) ] ) <EOL> def testSum ( self ) : <EOL> self . assertEqual ( <NUM_LIT:6> , sum ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) ) <EOL> self . assertEqual ( <NUM_LIT:5> , sum ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , - <NUM_LIT:1> ) ) <EOL> self . assertRaises ( TypeError , sum , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , "<STR_LIT:a>" ) <EOL> def testSlice ( self ) : <EOL> self . assertEqual ( repr ( slice ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> s1 = slice ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> s2 = slice ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> s3 = slice ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:4> ) <EOL> self . assertEqual ( s1 , s2 ) <EOL> self . assertNotEqual ( s1 , s3 , "<STR_LIT>" ) <EOL> try : <EOL> s = slice ( <NUM_LIT:1> ) <EOL> except Exception , e : <EOL> self . fail ( "<STR_LIT>" ) <EOL> return False <EOL> self . assertEqual ( s . start , None ) <EOL> self . assertEqual ( s . stop , <NUM_LIT:1> ) <EOL> self . assertEqual ( s . step , None ) <EOL> s = slice ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> self . assertEqual ( s . start , <NUM_LIT:1> ) <EOL> self . assertEqual ( s . stop , <NUM_LIT:2> ) <EOL> self . assertEqual ( s . step , None ) <EOL> s = slice ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> self . assertEqual ( s . start , <NUM_LIT:1> ) <EOL> self . assertEqual ( s . stop , <NUM_LIT:2> ) <EOL> self . assertEqual ( s . step , <NUM_LIT:3> ) <EOL> class AnyClass : <EOL> pass <EOL> obj = AnyClass ( ) <EOL> s = slice ( obj ) <EOL> self . assertTrue ( s . stop is obj ) <EOL> self . assertEqual ( slice ( None ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , None , <NUM_LIT:2> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:2> ) ) <EOL> self . assertEqual ( slice ( <NUM_LIT:1> , None , <NUM_LIT:2> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:1> , <NUM_LIT:10> , <NUM_LIT:2> ) ) <EOL> self . assertEqual ( slice ( None , None , - <NUM_LIT:1> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:9> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , None , - <NUM_LIT:2> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:9> , - <NUM_LIT:1> , - <NUM_LIT:2> ) ) <EOL> self . assertEqual ( slice ( <NUM_LIT:3> , None , - <NUM_LIT:2> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:3> , - <NUM_LIT:1> , - <NUM_LIT:2> ) ) <EOL> self . assertEqual ( slice ( None , - <NUM_LIT:9> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , - <NUM_LIT:10> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , - <NUM_LIT:11> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , - <NUM_LIT:10> , - <NUM_LIT:1> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:9> , <NUM_LIT:0> , - <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , - <NUM_LIT:11> , - <NUM_LIT:1> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:9> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , - <NUM_LIT:12> , - <NUM_LIT:1> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:9> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , <NUM_LIT:9> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:0> , <NUM_LIT:9> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , <NUM_LIT:10> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , <NUM_LIT:11> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , <NUM_LIT:8> , - <NUM_LIT:1> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:9> , <NUM_LIT:8> , - <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , <NUM_LIT:9> , - <NUM_LIT:1> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:9> , <NUM_LIT:9> , - <NUM_LIT:1> ) ) <EOL> self . assertEqual ( slice ( None , <NUM_LIT:10> , - <NUM_LIT:1> ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:9> , <NUM_LIT:9> , - <NUM_LIT:1> ) ) <EOL> self . assertEqual ( <EOL> slice ( - <NUM_LIT:100> , <NUM_LIT:100> ) . indices ( <NUM_LIT:10> ) , <EOL> slice ( None ) . indices ( <NUM_LIT:10> ) <EOL> ) <EOL> self . assertEqual ( <EOL> slice ( <NUM_LIT:100> , - <NUM_LIT:100> , - <NUM_LIT:1> ) . indices ( <NUM_LIT:10> ) , <EOL> slice ( None , None , - <NUM_LIT:1> ) . indices ( <NUM_LIT:10> ) <EOL> ) <EOL> self . assertEqual ( slice ( - <NUM_LIT:100> L , <NUM_LIT:100> L , <NUM_LIT:2> L ) . indices ( <NUM_LIT:10> ) , ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:2> ) ) </s>
