<s> '''<STR_LIT>''' <EOL> from pyon . util . set import OrderedSet <EOL> from pyon . util . unit_test import PyonTestCase <EOL> from nose . plugins . attrib import attr <EOL> from copy import copy <EOL> @ attr ( '<STR_LIT>' ) <EOL> class OrderedSetTest ( PyonTestCase ) : <EOL> def test_set_ops ( self ) : <EOL> os = OrderedSet ( [ <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:9> , <NUM_LIT:8> , <NUM_LIT:12> , <NUM_LIT> ] ) <EOL> compare_list = [ <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:9> , <NUM_LIT:8> , <NUM_LIT:12> , <NUM_LIT> ] <EOL> self . assertEquals ( list ( os ) , compare_list ) <EOL> os . add ( <NUM_LIT:2> ) <EOL> self . assertEquals ( list ( os ) , compare_list ) <EOL> os . add ( <NUM_LIT> ) <EOL> self . assertEquals ( list ( os ) , compare_list + [ <NUM_LIT> ] ) <EOL> val = os . pop ( ) <EOL> self . assertEquals ( val , <NUM_LIT> ) <EOL> self . assertEquals ( list ( os ) , compare_list ) <EOL> self . assertEquals ( [ i for i in os ] , compare_list ) <EOL> self . assertEquals ( len ( list ( os ) ) , len ( os ) ) <EOL> cmpval = copy ( compare_list ) <EOL> cmpval . reverse ( ) <EOL> self . assertEquals ( [ i for i in reversed ( os ) ] , cmpval ) <EOL> self . assertTrue ( os == compare_list ) <EOL> os2 = OrderedSet ( compare_list ) <EOL> self . assertTrue ( os == os2 ) <EOL> self . assertTrue ( <NUM_LIT:8> in os ) <EOL> os . discard ( <NUM_LIT:8> ) <EOL> self . assertFalse ( <NUM_LIT:8> in os ) <EOL> with self . assertRaises ( KeyError ) : <EOL> os2 = OrderedSet ( [ ] ) <EOL> os2 . pop ( ) </s>
