def test_organize_commands():
 commands = [CorrectedCommand('ls'), CorrectedCommand('ls -la', priority=9000), CorrectedCommand('ls -lh', priority=100), CorrectedCommand(u'echo caf\xe9', priority=200), CorrectedCommand('ls -lh', priority=9999)]
 assert (list(organize_commands(iter(commands))) == [CorrectedCommand('ls'), CorrectedCommand('ls -lh', priority=100), CorrectedCommand(u'echo caf\xe9', priority=200), CorrectedCommand('ls -la', priority=9000)])

def test_organize_commands ( ) : commands = [ CorrectedCommand ( 'ls' ) , CorrectedCommand ( 'ls -la' , priority = 9000 ) , CorrectedCommand ( 'ls -lh' , priority = 100 ) , CorrectedCommand ( u'echo caf\xe9' , priority = 200 ) , CorrectedCommand ( 'ls -lh' , priority = 9999 ) ] assert ( list ( organize_commands ( iter ( commands ) ) ) == [ CorrectedCommand ( 'ls' ) , CorrectedCommand ( 'ls -lh' , priority = 100 ) , CorrectedCommand ( u'echo caf\xe9' , priority = 200 ) , CorrectedCommand ( 'ls -la' , priority = 9000 ) ] )
ensures that the function removes duplicates and sorts commands .