<s> from random import randint <EOL> from nose . tools import assert_equal <EOL> class TestSortStack ( object ) : <EOL> def get_sorted_stack ( self , stack , numbers ) : <EOL> for x in numbers : <EOL> stack . push ( x ) <EOL> sorted_stack = stack . sort ( ) <EOL> return sorted_stack <EOL> def test_sort_stack ( self , stack ) : <EOL> print ( '<STR_LIT>' ) <EOL> sorted_stack = self . get_sorted_stack ( stack , [ ] ) <EOL> assert_equal ( sorted_stack . pop ( ) , None ) <EOL> print ( '<STR_LIT>' ) <EOL> sorted_stack = self . get_sorted_stack ( stack , [ <NUM_LIT:1> ] ) <EOL> assert_equal ( sorted_stack . pop ( ) , <NUM_LIT:1> ) <EOL> print ( '<STR_LIT>' ) <EOL> num_items = <NUM_LIT:10> <EOL> numbers = [ randint ( <NUM_LIT:0> , <NUM_LIT:10> ) for x in range ( num_items ) ] <EOL> sorted_stack = self . get_sorted_stack ( stack , numbers ) <EOL> sorted_numbers = [ ] <EOL> for _ in range ( num_items ) : <EOL> sorted_numbers . append ( sorted_stack . pop ( ) ) <EOL> assert_equal ( sorted_numbers , sorted ( numbers , reverse = True ) ) <EOL> print ( '<STR_LIT>' ) <EOL> def main ( ) : <EOL> test = TestSortStack ( ) <EOL> test . test_sort_stack ( MyStack ( ) ) <EOL> test . test_sort_stack ( MyStackSimplified ( ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
