<s> from sys import hexversion <EOL> import random <EOL> from . context import sortedcontainers <EOL> from sortedcontainers import SortedList <EOL> from itertools import chain <EOL> from nose . tools import raises <EOL> if hexversion < <NUM_LIT> : <EOL> from itertools import izip as zip <EOL> range = xrange <EOL> def test_init ( ) : <EOL> slt = SortedList ( ) <EOL> slt . _check ( ) <EOL> slt = SortedList ( load = <NUM_LIT> ) <EOL> assert slt . _load == <NUM_LIT> <EOL> assert slt . _twice == <NUM_LIT> <EOL> assert slt . _half == <NUM_LIT> <EOL> slt . _check ( ) <EOL> slt = SortedList ( range ( <NUM_LIT> ) ) <EOL> assert all ( tup [ <NUM_LIT:0> ] == tup [ <NUM_LIT:1> ] for tup in zip ( slt , range ( <NUM_LIT> ) ) ) <EOL> slt . clear ( ) <EOL> assert slt . _len == <NUM_LIT:0> <EOL> assert slt . _maxes == [ ] <EOL> assert slt . _lists == [ ] <EOL> slt . _check ( ) <EOL> def test_add ( ) : <EOL> random . seed ( <NUM_LIT:0> ) <EOL> slt = SortedList ( ) <EOL> for val in range ( <NUM_LIT:1000> ) : <EOL> slt . add ( val ) <EOL> slt . _check ( ) <EOL> slt = SortedList ( ) <EOL> for val in range ( <NUM_LIT:1000> , <NUM_LIT:0> , - <NUM_LIT:1> ) : <EOL> slt . add ( val ) <EOL> slt . _check ( ) <EOL> slt = SortedList ( ) <EOL> for val in range ( <NUM_LIT:1000> ) : <EOL> slt . add ( random . random ( ) ) <EOL> slt . _check ( ) <EOL> def test_update ( ) : <EOL> slt = SortedList ( ) <EOL> slt . update ( range ( <NUM_LIT:1000> ) ) <EOL> assert len ( slt ) == <NUM_LIT:1000> <EOL> slt . _check ( ) <EOL> slt . update ( range ( <NUM_LIT:100> ) ) <EOL> assert len ( slt ) == <NUM_LIT> <EOL> slt . _check ( ) <EOL> slt . update ( range ( <NUM_LIT> ) ) <EOL> assert len ( slt ) == <NUM_LIT> <EOL> slt . _check ( ) <EOL> values = sorted ( chain ( range ( <NUM_LIT:1000> ) , range ( <NUM_LIT:100> ) , range ( <NUM_LIT> ) ) ) <EOL> assert all ( tup [ <NUM_LIT:0> ] == tup [ <NUM_LIT:1> ] for tup in zip ( slt , values ) ) <EOL> def test_contains ( ) : <EOL> slt = SortedList ( ) <EOL> assert <NUM_LIT:0> not in slt <EOL> slt . update ( range ( <NUM_LIT> ) ) <EOL> for val in range ( <NUM_LIT> ) : <EOL> assert val in slt <EOL> assert <NUM_LIT> not in slt <EOL> slt . _check ( ) <EOL> def test_discard ( ) : <EOL> slt = SortedList ( ) <EOL> assert slt . discard ( <NUM_LIT:0> ) == None <EOL> assert len ( slt ) == <NUM_LIT:0> <EOL> slt . _check ( ) <EOL> slt = SortedList ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:5> ] , load = <NUM_LIT:4> ) <EOL> slt . discard ( <NUM_LIT:6> ) <EOL> slt . _check ( ) <EOL> slt . discard ( <NUM_LIT:4> ) <EOL> slt . _check ( ) <EOL> slt . discard ( <NUM_LIT:2> ) <EOL> slt . _check ( ) <EOL> assert all ( tup [ <NUM_LIT:0> ] == tup [ <NUM_LIT:1> ] for tup in zip ( slt , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:5> ] ) ) <EOL> def test_remove ( ) : <EOL> slt = SortedList ( ) <EOL> assert slt . discard ( <NUM_LIT:0> ) == None <EOL> assert len ( slt ) == <NUM_LIT:0> <EOL> slt . _check ( ) <EOL> slt = SortedList ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:5> ] , load = <NUM_LIT:4> ) <EOL> slt . remove ( <NUM_LIT:2> ) <EOL> slt . _check ( ) <EOL> assert all ( tup [ <NUM_LIT:0> ] == tup [ <NUM_LIT:1> ] for tup in zip ( slt , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:5> ] ) ) <EOL> @ raises ( ValueError ) <EOL> def test_remove_valueerror1 ( ) : <EOL> slt = SortedList ( ) <EOL> slt . remove ( <NUM_LIT:0> ) <EOL> @ raises ( ValueError ) <EOL> def test_remove_valueerror2 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT:10> ) <EOL> slt . remove ( <NUM_LIT:100> ) <EOL> @ raises ( ValueError ) <EOL> def test_remove_valueerror3 ( ) : <EOL> slt = SortedList ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:5> ] ) <EOL> slt . remove ( <NUM_LIT:4> ) <EOL> def test_delete ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:20> ) , load = <NUM_LIT:4> ) <EOL> slt . _check ( ) <EOL> for val in range ( <NUM_LIT:20> ) : <EOL> slt . remove ( val ) <EOL> slt . _check ( ) <EOL> assert len ( slt ) == <NUM_LIT:0> <EOL> assert slt . _maxes == [ ] <EOL> assert slt . _lists == [ ] <EOL> def test_getitem ( ) : <EOL> random . seed ( <NUM_LIT:0> ) <EOL> slt = SortedList ( load = <NUM_LIT> ) <EOL> lst = list ( ) <EOL> for rpt in range ( <NUM_LIT:100> ) : <EOL> val = random . random ( ) <EOL> slt . add ( val ) <EOL> lst . append ( val ) <EOL> lst . sort ( ) <EOL> assert all ( slt [ idx ] == lst [ idx ] for idx in range ( <NUM_LIT:100> ) ) <EOL> assert all ( slt [ idx - <NUM_LIT> ] == lst [ idx - <NUM_LIT> ] for idx in range ( <NUM_LIT:100> ) ) <EOL> def test_getitem_slice ( ) : <EOL> random . seed ( <NUM_LIT:0> ) <EOL> slt = SortedList ( load = <NUM_LIT> ) <EOL> lst = list ( ) <EOL> for rpt in range ( <NUM_LIT:100> ) : <EOL> val = random . random ( ) <EOL> slt . add ( val ) <EOL> lst . append ( val ) <EOL> lst . sort ( ) <EOL> assert all ( slt [ start : ] == lst [ start : ] <EOL> for start in [ - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert all ( slt [ : stop ] == lst [ : stop ] <EOL> for stop in [ - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert all ( slt [ : : step ] == lst [ : : step ] <EOL> for step in [ - <NUM_LIT:5> , - <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> assert all ( slt [ start : stop ] == lst [ start : stop ] <EOL> for start in [ - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ] <EOL> for stop in [ - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert all ( slt [ : stop : step ] == lst [ : stop : step ] <EOL> for stop in [ - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ] <EOL> for step in [ - <NUM_LIT:5> , - <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> assert all ( slt [ start : : step ] == lst [ start : : step ] <EOL> for start in [ - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ] <EOL> for step in [ - <NUM_LIT:5> , - <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> assert all ( slt [ start : stop : step ] == lst [ start : stop : step ] <EOL> for start in [ - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ] <EOL> for stop in [ - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ] <EOL> for step in [ - <NUM_LIT:5> , - <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> def test_getitem_slice_big ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:4> ) ) <EOL> lst = list ( range ( <NUM_LIT:4> ) ) <EOL> itr = ( ( start , stop , step ) <EOL> for start in [ - <NUM_LIT:6> , - <NUM_LIT:4> , - <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:6> ] <EOL> for stop in [ - <NUM_LIT:6> , - <NUM_LIT:4> , - <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:6> ] <EOL> for step in [ - <NUM_LIT:3> , - <NUM_LIT:2> , - <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> for start , stop , step in itr : <EOL> assert slt [ start : stop : step ] == lst [ start : stop : step ] <EOL> @ raises ( ValueError ) <EOL> def test_getitem_slicezero ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> slt [ : : <NUM_LIT:0> ] <EOL> @ raises ( IndexError ) <EOL> def test_getitem_indexerror1 ( ) : <EOL> slt = SortedList ( ) <EOL> slt [ <NUM_LIT:5> ] <EOL> @ raises ( IndexError ) <EOL> def test_getitem_indexerror2 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) ) <EOL> slt [ <NUM_LIT:200> ] <EOL> @ raises ( IndexError ) <EOL> def test_getitem_indexerror3 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) ) <EOL> slt [ - <NUM_LIT> ] <EOL> def test_delitem ( ) : <EOL> random . seed ( <NUM_LIT:0> ) <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> while len ( slt ) > <NUM_LIT:0> : <EOL> pos = random . randrange ( len ( slt ) ) <EOL> del slt [ pos ] <EOL> slt . _check ( ) <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> del slt [ : ] <EOL> assert len ( slt ) == <NUM_LIT:0> <EOL> slt . _check ( ) <EOL> def test_delitem_slice ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> del slt [ <NUM_LIT:10> : <NUM_LIT> : <NUM_LIT:1> ] <EOL> del slt [ <NUM_LIT:10> : <NUM_LIT> : - <NUM_LIT:1> ] <EOL> del slt [ <NUM_LIT:10> : <NUM_LIT> : <NUM_LIT:2> ] <EOL> del slt [ <NUM_LIT:10> : <NUM_LIT> : - <NUM_LIT:2> ] <EOL> def test_setitem ( ) : <EOL> random . seed ( <NUM_LIT:0> ) <EOL> slt = SortedList ( range ( <NUM_LIT:0> , <NUM_LIT:100> , <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> values = list ( enumerate ( range ( <NUM_LIT:5> , <NUM_LIT> , <NUM_LIT:10> ) ) ) <EOL> random . shuffle ( values ) <EOL> for pos , val in values : <EOL> slt [ pos ] = val <EOL> slt [ - <NUM_LIT:2> ] = <NUM_LIT> <EOL> slt . _check ( ) <EOL> def test_setitem_slice ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> slt [ : <NUM_LIT:10> ] = iter ( range ( <NUM_LIT:10> ) ) <EOL> assert slt == list ( range ( <NUM_LIT:100> ) ) <EOL> slt [ : <NUM_LIT:10> : <NUM_LIT:2> ] = iter ( val * <NUM_LIT:2> for val in range ( <NUM_LIT:5> ) ) <EOL> assert slt == list ( range ( <NUM_LIT:100> ) ) <EOL> slt [ : <NUM_LIT:50> ] = range ( - <NUM_LIT:50> , <NUM_LIT:50> ) <EOL> assert slt == list ( range ( - <NUM_LIT:50> , <NUM_LIT:100> ) ) <EOL> slt [ : <NUM_LIT:100> ] = range ( <NUM_LIT:50> ) <EOL> assert slt == list ( range ( <NUM_LIT:100> ) ) <EOL> slt [ : ] = range ( <NUM_LIT:100> ) <EOL> assert slt == list ( range ( <NUM_LIT:100> ) ) <EOL> slt [ <NUM_LIT> : ] = [ ] <EOL> assert slt == list ( range ( <NUM_LIT> ) ) <EOL> slt [ : <NUM_LIT:10> ] = [ ] <EOL> assert slt == list ( range ( <NUM_LIT:10> , <NUM_LIT> ) ) <EOL> slt . _check ( ) <EOL> @ raises ( ValueError ) <EOL> def test_setitem_slice_bad ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> slt [ : <NUM_LIT:10> ] = list ( reversed ( range ( <NUM_LIT:10> ) ) ) <EOL> @ raises ( ValueError ) <EOL> def test_setitem_slice_bad1 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> slt [ <NUM_LIT:10> : <NUM_LIT:20> ] = range ( <NUM_LIT:20> , <NUM_LIT:30> ) <EOL> @ raises ( ValueError ) <EOL> def test_setitem_slice_bad2 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> slt [ <NUM_LIT:20> : <NUM_LIT:30> ] = range ( <NUM_LIT:10> , <NUM_LIT:20> ) <EOL> def test_setitem_extended_slice ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:0> , <NUM_LIT:1000> , <NUM_LIT:10> ) , load = <NUM_LIT> ) <EOL> lst = list ( range ( <NUM_LIT:0> , <NUM_LIT:1000> , <NUM_LIT:10> ) ) <EOL> lst [ <NUM_LIT:10> : <NUM_LIT> : <NUM_LIT:10> ] = range ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT:100> ) <EOL> slt [ <NUM_LIT:10> : <NUM_LIT> : <NUM_LIT:10> ] = range ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT:100> ) <EOL> assert slt == lst <EOL> slt . _check ( ) <EOL> @ raises ( ValueError ) <EOL> def test_setitem_extended_slice_bad1 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> slt [ <NUM_LIT:20> : <NUM_LIT> : <NUM_LIT:3> ] = list ( range ( <NUM_LIT:10> ) ) <EOL> @ raises ( ValueError ) <EOL> def test_setitem_extended_slice_bad2 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> slt [ <NUM_LIT> : <NUM_LIT> : <NUM_LIT:5> ] = list ( range ( <NUM_LIT:10> ) ) <EOL> @ raises ( ValueError ) <EOL> def test_setitem_valueerror1 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) ) <EOL> slt [ <NUM_LIT:9> ] = <NUM_LIT:0> <EOL> @ raises ( ValueError ) <EOL> def test_setitem_valueerror2 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) ) <EOL> slt [ <NUM_LIT:0> ] = <NUM_LIT:10> <EOL> def test_iter ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT> ) ) <EOL> itr = iter ( slt ) <EOL> assert all ( tup [ <NUM_LIT:0> ] == tup [ <NUM_LIT:1> ] for tup in zip ( range ( <NUM_LIT> ) , itr ) ) <EOL> def test_reversed ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT> ) ) <EOL> rev = reversed ( slt ) <EOL> assert all ( tup [ <NUM_LIT:0> ] == tup [ <NUM_LIT:1> ] for tup in zip ( range ( <NUM_LIT> , - <NUM_LIT:1> , - <NUM_LIT:1> ) , rev ) ) <EOL> def test_islice ( ) : <EOL> sl = SortedList ( load = <NUM_LIT:7> ) <EOL> assert [ ] == list ( sl . islice ( ) ) <EOL> values = list ( range ( <NUM_LIT> ) ) <EOL> sl . update ( values ) <EOL> for start in range ( <NUM_LIT> ) : <EOL> for stop in range ( <NUM_LIT> ) : <EOL> assert list ( sl . islice ( start , stop ) ) == values [ start : stop ] <EOL> for start in range ( <NUM_LIT> ) : <EOL> for stop in range ( <NUM_LIT> ) : <EOL> assert list ( sl . islice ( start , stop , reverse = True ) ) == values [ start : stop ] [ : : - <NUM_LIT:1> ] <EOL> for start in range ( <NUM_LIT> ) : <EOL> assert list ( sl . islice ( start = start ) ) == values [ start : ] <EOL> assert list ( sl . islice ( start = start , reverse = True ) ) == values [ start : ] [ : : - <NUM_LIT:1> ] <EOL> for stop in range ( <NUM_LIT> ) : <EOL> assert list ( sl . islice ( stop = stop ) ) == values [ : stop ] <EOL> assert list ( sl . islice ( stop = stop , reverse = True ) ) == values [ : stop ] [ : : - <NUM_LIT:1> ] <EOL> def test_irange ( ) : <EOL> sl = SortedList ( load = <NUM_LIT:7> ) <EOL> assert [ ] == list ( sl . irange ( ) ) <EOL> values = list ( range ( <NUM_LIT> ) ) <EOL> sl . update ( values ) <EOL> for start in range ( <NUM_LIT> ) : <EOL> for end in range ( start , <NUM_LIT> ) : <EOL> assert list ( sl . irange ( start , end ) ) == values [ start : ( end + <NUM_LIT:1> ) ] <EOL> assert list ( sl . irange ( start , end , reverse = True ) ) == values [ start : ( end + <NUM_LIT:1> ) ] [ : : - <NUM_LIT:1> ] <EOL> for start in range ( <NUM_LIT> ) : <EOL> for end in range ( start , <NUM_LIT> ) : <EOL> assert list ( range ( start , end ) ) == list ( sl . irange ( start , end , ( True , False ) ) ) <EOL> for start in range ( <NUM_LIT> ) : <EOL> for end in range ( start , <NUM_LIT> ) : <EOL> assert list ( range ( start + <NUM_LIT:1> , end + <NUM_LIT:1> ) ) == list ( sl . irange ( start , end , ( False , True ) ) ) <EOL> for start in range ( <NUM_LIT> ) : <EOL> for end in range ( start , <NUM_LIT> ) : <EOL> assert list ( range ( start + <NUM_LIT:1> , end ) ) == list ( sl . irange ( start , end , ( False , False ) ) ) <EOL> for start in range ( <NUM_LIT> ) : <EOL> assert list ( range ( start , <NUM_LIT> ) ) == list ( sl . irange ( start ) ) <EOL> for end in range ( <NUM_LIT> ) : <EOL> assert list ( range ( <NUM_LIT:0> , end ) ) == list ( sl . irange ( None , end , ( True , False ) ) ) <EOL> assert values == list ( sl . irange ( inclusive = ( False , False ) ) ) <EOL> assert [ ] == list ( sl . irange ( <NUM_LIT> ) ) <EOL> assert values == list ( sl . irange ( None , <NUM_LIT> , ( True , False ) ) ) <EOL> def test_len ( ) : <EOL> slt = SortedList ( ) <EOL> for val in range ( <NUM_LIT> ) : <EOL> slt . add ( val ) <EOL> assert len ( slt ) == ( val + <NUM_LIT:1> ) <EOL> def test_bisect_left ( ) : <EOL> slt = SortedList ( ) <EOL> assert slt . bisect_left ( <NUM_LIT:0> ) == <NUM_LIT:0> <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> slt . update ( range ( <NUM_LIT:100> ) ) <EOL> slt . _check ( ) <EOL> assert slt . bisect_left ( <NUM_LIT:50> ) == <NUM_LIT:100> <EOL> assert slt . bisect_left ( <NUM_LIT:200> ) == <NUM_LIT:200> <EOL> def test_bisect ( ) : <EOL> slt = SortedList ( ) <EOL> assert slt . bisect ( <NUM_LIT:10> ) == <NUM_LIT:0> <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> slt . update ( range ( <NUM_LIT:100> ) ) <EOL> slt . _check ( ) <EOL> assert slt . bisect ( <NUM_LIT:10> ) == <NUM_LIT> <EOL> assert slt . bisect ( <NUM_LIT:200> ) == <NUM_LIT:200> <EOL> def test_bisect_right ( ) : <EOL> slt = SortedList ( ) <EOL> assert slt . bisect_right ( <NUM_LIT:10> ) == <NUM_LIT:0> <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> slt . update ( range ( <NUM_LIT:100> ) ) <EOL> slt . _check ( ) <EOL> assert slt . bisect_right ( <NUM_LIT:10> ) == <NUM_LIT> <EOL> assert slt . bisect_right ( <NUM_LIT:200> ) == <NUM_LIT:200> <EOL> def test_copy ( ) : <EOL> alpha = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT:7> ) <EOL> beta = alpha . copy ( ) <EOL> alpha . add ( <NUM_LIT:100> ) <EOL> assert len ( alpha ) == <NUM_LIT> <EOL> assert len ( beta ) == <NUM_LIT:100> <EOL> def test_copy_copy ( ) : <EOL> import copy <EOL> alpha = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT:7> ) <EOL> beta = copy . copy ( alpha ) <EOL> alpha . add ( <NUM_LIT:100> ) <EOL> assert len ( alpha ) == <NUM_LIT> <EOL> assert len ( beta ) == <NUM_LIT:100> <EOL> def test_count ( ) : <EOL> slt = SortedList ( load = <NUM_LIT:7> ) <EOL> assert slt . count ( <NUM_LIT:0> ) == <NUM_LIT:0> <EOL> for iii in range ( <NUM_LIT:100> ) : <EOL> for jjj in range ( iii ) : <EOL> slt . add ( iii ) <EOL> slt . _check ( ) <EOL> for iii in range ( <NUM_LIT:100> ) : <EOL> assert slt . count ( iii ) == iii <EOL> assert slt . count ( <NUM_LIT:100> ) == <NUM_LIT:0> <EOL> def test_append ( ) : <EOL> slt = SortedList ( load = <NUM_LIT> ) <EOL> slt . append ( <NUM_LIT:0> ) <EOL> for val in range ( <NUM_LIT:1> , <NUM_LIT:1000> ) : <EOL> slt . append ( val ) <EOL> slt . _check ( ) <EOL> @ raises ( ValueError ) <EOL> def test_append_valueerror ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) ) <EOL> slt . append ( <NUM_LIT:5> ) <EOL> def test_extend ( ) : <EOL> slt = SortedList ( load = <NUM_LIT> ) <EOL> slt . extend ( range ( <NUM_LIT:100> ) ) <EOL> slt . _check ( ) <EOL> slt . extend ( list ( range ( <NUM_LIT:100> , <NUM_LIT:200> ) ) ) <EOL> slt . _check ( ) <EOL> for val in range ( <NUM_LIT:200> , <NUM_LIT> ) : <EOL> del slt . _index [ : ] <EOL> slt . _build_index ( ) <EOL> slt . extend ( [ val ] * ( val - <NUM_LIT> ) ) <EOL> slt . _check ( ) <EOL> @ raises ( ValueError ) <EOL> def test_extend_valueerror1 ( ) : <EOL> slt = SortedList ( ) <EOL> slt . extend ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:6> ] ) <EOL> @ raises ( ValueError ) <EOL> def test_extend_valueerror2 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:20> ) , load = <NUM_LIT:4> ) <EOL> slt . extend ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> def test_insert ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . insert ( - <NUM_LIT:1> , <NUM_LIT:9> ) <EOL> slt . _check ( ) <EOL> slt . insert ( - <NUM_LIT:100> , <NUM_LIT:0> ) <EOL> slt . _check ( ) <EOL> slt . insert ( <NUM_LIT:100> , <NUM_LIT:10> ) <EOL> slt . _check ( ) <EOL> slt = SortedList ( load = <NUM_LIT:4> ) <EOL> slt . insert ( <NUM_LIT:0> , <NUM_LIT:5> ) <EOL> slt . _check ( ) <EOL> slt = SortedList ( range ( <NUM_LIT:5> , <NUM_LIT:15> ) , load = <NUM_LIT:4> ) <EOL> for rpt in range ( <NUM_LIT:8> ) : <EOL> slt . insert ( <NUM_LIT:0> , <NUM_LIT:4> ) <EOL> slt . _check ( ) <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . insert ( <NUM_LIT:8> , <NUM_LIT:8> ) <EOL> slt . _check ( ) <EOL> @ raises ( ValueError ) <EOL> def test_insert_valueerror1 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . insert ( <NUM_LIT:10> , <NUM_LIT:5> ) <EOL> @ raises ( ValueError ) <EOL> def test_insert_valueerror2 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . insert ( <NUM_LIT:0> , <NUM_LIT:10> ) <EOL> @ raises ( ValueError ) <EOL> def test_insert_valueerror3 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . insert ( <NUM_LIT:5> , <NUM_LIT:3> ) <EOL> @ raises ( ValueError ) <EOL> def test_insert_valueerror4 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . insert ( <NUM_LIT:5> , <NUM_LIT:7> ) <EOL> def test_pop ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . _check ( ) <EOL> assert slt . pop ( ) == <NUM_LIT:9> <EOL> slt . _check ( ) <EOL> assert slt . pop ( <NUM_LIT:0> ) == <NUM_LIT:0> <EOL> slt . _check ( ) <EOL> assert slt . pop ( - <NUM_LIT:2> ) == <NUM_LIT:7> <EOL> slt . _check ( ) <EOL> assert slt . pop ( <NUM_LIT:4> ) == <NUM_LIT:5> <EOL> slt . _check ( ) <EOL> @ raises ( IndexError ) <EOL> def test_pop_indexerror1 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . pop ( - <NUM_LIT:11> ) <EOL> @ raises ( IndexError ) <EOL> def test_pop_indexerror2 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . pop ( <NUM_LIT:10> ) <EOL> @ raises ( IndexError ) <EOL> def test_pop_indexerror3 ( ) : <EOL> slt = SortedList ( ) <EOL> slt . pop ( ) <EOL> def test_index ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:100> ) , load = <NUM_LIT> ) <EOL> for val in range ( <NUM_LIT:100> ) : <EOL> assert val == slt . index ( val ) <EOL> assert slt . index ( <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:1000> ) == <NUM_LIT> <EOL> slt = SortedList ( ( <NUM_LIT:0> for rpt in range ( <NUM_LIT:100> ) ) , load = <NUM_LIT> ) <EOL> for start in range ( <NUM_LIT:100> ) : <EOL> for stop in range ( start , <NUM_LIT:100> ) : <EOL> assert slt . index ( <NUM_LIT:0> , start , stop + <NUM_LIT:1> ) == start <EOL> for start in range ( <NUM_LIT:100> ) : <EOL> assert slt . index ( <NUM_LIT:0> , - ( <NUM_LIT:100> - start ) ) == start <EOL> assert slt . index ( <NUM_LIT:0> , - <NUM_LIT:1000> ) == <NUM_LIT:0> <EOL> @ raises ( ValueError ) <EOL> def test_index_valueerror1 ( ) : <EOL> slt = SortedList ( [ <NUM_LIT:0> ] * <NUM_LIT:10> , load = <NUM_LIT:4> ) <EOL> slt . index ( <NUM_LIT:0> , <NUM_LIT:10> ) <EOL> @ raises ( ValueError ) <EOL> def test_index_valueerror2 ( ) : <EOL> slt = SortedList ( [ <NUM_LIT:0> ] * <NUM_LIT:10> , load = <NUM_LIT:4> ) <EOL> slt . index ( <NUM_LIT:0> , <NUM_LIT:0> , - <NUM_LIT:10> ) <EOL> @ raises ( ValueError ) <EOL> def test_index_valueerror3 ( ) : <EOL> slt = SortedList ( [ <NUM_LIT:0> ] * <NUM_LIT:10> , load = <NUM_LIT:4> ) <EOL> slt . index ( <NUM_LIT:0> , <NUM_LIT:7> , <NUM_LIT:3> ) <EOL> @ raises ( ValueError ) <EOL> def test_index_valueerror4 ( ) : <EOL> slt = SortedList ( [ <NUM_LIT:0> ] * <NUM_LIT:10> , load = <NUM_LIT:4> ) <EOL> slt . index ( <NUM_LIT:1> ) <EOL> @ raises ( ValueError ) <EOL> def test_index_valueerror5 ( ) : <EOL> slt = SortedList ( ) <EOL> slt . index ( <NUM_LIT:1> ) <EOL> @ raises ( ValueError ) <EOL> def test_index_valueerror6 ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . index ( <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> @ raises ( ValueError ) <EOL> def test_index_valueerror7 ( ) : <EOL> slt = SortedList ( [ <NUM_LIT:0> ] * <NUM_LIT:10> + [ <NUM_LIT:2> ] * <NUM_LIT:10> , load = <NUM_LIT:4> ) <EOL> slt . index ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:10> ) <EOL> def test_mul ( ) : <EOL> this = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> that = this * <NUM_LIT:5> <EOL> this . _check ( ) <EOL> that . _check ( ) <EOL> assert this == list ( range ( <NUM_LIT:10> ) ) <EOL> assert that == sorted ( list ( range ( <NUM_LIT:10> ) ) * <NUM_LIT:5> ) <EOL> assert this != that <EOL> def test_imul ( ) : <EOL> this = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> this *= <NUM_LIT:5> <EOL> this . _check ( ) <EOL> assert this == sorted ( list ( range ( <NUM_LIT:10> ) ) * <NUM_LIT:5> ) <EOL> def test_op_add ( ) : <EOL> this = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> assert ( this + this + this ) == ( this * <NUM_LIT:3> ) <EOL> that = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> that += that <EOL> that += that <EOL> assert that == ( this * <NUM_LIT:4> ) <EOL> def test_eq ( ) : <EOL> this = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> assert this == list ( range ( <NUM_LIT:10> ) ) <EOL> assert this == tuple ( range ( <NUM_LIT:10> ) ) <EOL> assert not ( this == list ( range ( <NUM_LIT:9> ) ) ) <EOL> def test_ne ( ) : <EOL> this = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> assert this != list ( range ( <NUM_LIT:9> ) ) <EOL> assert this != tuple ( range ( <NUM_LIT:11> ) ) <EOL> assert this != [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] <EOL> assert this != ( val for val in range ( <NUM_LIT:10> ) ) <EOL> assert this != set ( ) <EOL> def test_lt ( ) : <EOL> this = SortedList ( range ( <NUM_LIT:10> , <NUM_LIT:15> ) , load = <NUM_LIT:4> ) <EOL> assert this < [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert this < [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:15> ] <EOL> assert this < [ <NUM_LIT:11> ] <EOL> def test_le ( ) : <EOL> this = SortedList ( range ( <NUM_LIT:10> , <NUM_LIT:15> ) , load = <NUM_LIT:4> ) <EOL> assert this <= [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert this <= [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:15> ] <EOL> assert this <= [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert this <= [ <NUM_LIT:11> ] <EOL> def test_gt ( ) : <EOL> this = SortedList ( range ( <NUM_LIT:10> , <NUM_LIT:15> ) , load = <NUM_LIT:4> ) <EOL> assert this > [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert this > [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> ] <EOL> assert this > [ <NUM_LIT:9> ] <EOL> def test_ge ( ) : <EOL> this = SortedList ( range ( <NUM_LIT:10> , <NUM_LIT:15> ) , load = <NUM_LIT:4> ) <EOL> assert this >= [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert this >= [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> ] <EOL> assert this >= [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert this >= [ <NUM_LIT:9> ] <EOL> def test_repr ( ) : <EOL> this = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> assert repr ( this ) == '<STR_LIT>' <EOL> def test_repr_recursion ( ) : <EOL> this = SortedList ( [ [ <NUM_LIT:1> ] , [ <NUM_LIT:2> ] , [ <NUM_LIT:3> ] , [ <NUM_LIT:4> ] ] ) <EOL> this . _lists [ - <NUM_LIT:1> ] . append ( this ) <EOL> assert repr ( this ) == '<STR_LIT>' <EOL> def test_repr_subclass ( ) : <EOL> class CustomSortedList ( SortedList ) : <EOL> pass <EOL> this = CustomSortedList ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> assert repr ( this ) == '<STR_LIT>' <EOL> def test_pickle ( ) : <EOL> import pickle <EOL> alpha = SortedList ( range ( <NUM_LIT> ) , load = <NUM_LIT> ) <EOL> beta = pickle . loads ( pickle . dumps ( alpha ) ) <EOL> assert alpha == beta <EOL> assert alpha . _load == beta . _load <EOL> def test_build_index ( ) : <EOL> slt = SortedList ( [ <NUM_LIT:0> ] , load = <NUM_LIT:4> ) <EOL> slt . _build_index ( ) <EOL> slt . _check ( ) <EOL> @ raises ( AssertionError ) <EOL> def test_check ( ) : <EOL> slt = SortedList ( range ( <NUM_LIT:10> ) , load = <NUM_LIT:4> ) <EOL> slt . _len = <NUM_LIT:5> <EOL> slt . _check ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import nose <EOL> nose . main ( ) </s>
