<s> import sys <EOL> from test import test_support , list_tests <EOL> class ListTest ( list_tests . CommonTest ) : <EOL> type2test = list <EOL> def test_basic ( self ) : <EOL> self . assertEqual ( list ( [ ] ) , [ ] ) <EOL> l0_3 = [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> l0_3_bis = list ( l0_3 ) <EOL> self . assertEqual ( l0_3 , l0_3_bis ) <EOL> self . assertTrue ( l0_3 is not l0_3_bis ) <EOL> self . assertEqual ( list ( ( ) ) , [ ] ) <EOL> self . assertEqual ( list ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> self . assertEqual ( list ( '<STR_LIT>' ) , [ ] ) <EOL> self . assertEqual ( list ( '<STR_LIT>' ) , [ '<STR_LIT:s>' , '<STR_LIT:p>' , '<STR_LIT:a>' , '<STR_LIT:m>' ] ) <EOL> if sys . maxsize == <NUM_LIT> : <EOL> self . assertRaises ( MemoryError , list , xrange ( sys . maxint // <NUM_LIT:2> ) ) <EOL> x = [ ] <EOL> x . extend ( - y for y in x ) <EOL> self . assertEqual ( x , [ ] ) <EOL> def test_truth ( self ) : <EOL> super ( ListTest , self ) . test_truth ( ) <EOL> self . assertTrue ( not [ ] ) <EOL> self . assertTrue ( [ <NUM_LIT> ] ) <EOL> def test_identity ( self ) : <EOL> self . assertTrue ( [ ] is not [ ] ) <EOL> def test_len ( self ) : <EOL> super ( ListTest , self ) . test_len ( ) <EOL> self . assertEqual ( len ( [ ] ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( [ <NUM_LIT:0> ] ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] ) , <NUM_LIT:3> ) <EOL> def test_overflow ( self ) : <EOL> lst = [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] <EOL> n = int ( ( sys . maxsize * <NUM_LIT:2> + <NUM_LIT:2> ) // len ( lst ) ) <EOL> def mul ( a , b ) : return a * b <EOL> def imul ( a , b ) : a *= b <EOL> self . assertRaises ( ( MemoryError , OverflowError ) , mul , lst , n ) <EOL> self . assertRaises ( ( MemoryError , OverflowError ) , imul , lst , n ) <EOL> def test_main ( verbose = None ) : <EOL> test_support . run_unittest ( ListTest ) <EOL> import sys <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 ( ListTest ) <EOL> gc . collect ( ) <EOL> counts [ i ] = sys . gettotalrefcount ( ) <EOL> print counts <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( verbose = True ) </s>
