<s> import unittest <EOL> import time <EOL> from robot . utils . asserts import assert_equal <EOL> from robot . utils import format_time <EOL> from robot . output . stdoutlogsplitter import StdoutLogSplitter as Splitter <EOL> class TestOutputSplitter ( unittest . TestCase ) : <EOL> def test_empty_output_should_result_in_empty_messages_list ( self ) : <EOL> splitter = Splitter ( '<STR_LIT>' ) <EOL> assert_equal ( list ( splitter ) , [ ] ) <EOL> def test_plain_output_should_have_info_level ( self ) : <EOL> splitter = Splitter ( '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' ) <EOL> assert_equal ( len ( list ( splitter ) ) , <NUM_LIT:1> ) <EOL> def test_leading_and_trailing_space_should_be_stripped ( self ) : <EOL> splitter = Splitter ( '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' ) <EOL> assert_equal ( len ( list ( splitter ) ) , <NUM_LIT:1> ) <EOL> def test_legal_level_is_correctly_read ( self ) : <EOL> splitter = Splitter ( '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert_equal ( len ( list ( splitter ) ) , <NUM_LIT:1> ) <EOL> def test_space_after_level_is_optional ( self ) : <EOL> splitter = Splitter ( '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert_equal ( len ( list ( splitter ) ) , <NUM_LIT:1> ) <EOL> def test_it_is_possible_to_define_multiple_levels ( self ) : <EOL> splitter = Splitter ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' , '<STR_LIT>' , index = <NUM_LIT:1> ) <EOL> assert_equal ( len ( list ( splitter ) ) , <NUM_LIT:2> ) <EOL> def test_html_flag_should_be_parsed_correctly_and_uses_info_level ( self ) : <EOL> splitter = Splitter ( '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' , level = '<STR_LIT>' , html = True ) <EOL> assert_equal ( len ( list ( splitter ) ) , <NUM_LIT:1> ) <EOL> def test_default_level_for_first_message_is_info ( self ) : <EOL> splitter = Splitter ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' , '<STR_LIT>' , index = <NUM_LIT:1> ) <EOL> assert_equal ( len ( list ( splitter ) ) , <NUM_LIT:2> ) <EOL> def test_timestamp_given_as_integer ( self ) : <EOL> now = int ( time . time ( ) ) <EOL> splitter = Splitter ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( now * <NUM_LIT:1000> ) ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' , timestamp = <NUM_LIT:0> , index = <NUM_LIT:1> ) <EOL> self . _verify_message ( splitter , html = True , timestamp = now , index = <NUM_LIT:2> ) <EOL> assert_equal ( len ( list ( splitter ) ) , <NUM_LIT:3> ) <EOL> def test_timestamp_given_as_float ( self ) : <EOL> splitter = Splitter ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , '<STR_LIT>' ) <EOL> self . _verify_message ( splitter , html = True , timestamp = <NUM_LIT:1> , index = <NUM_LIT:1> ) <EOL> self . _verify_message ( splitter , timestamp = <NUM_LIT> , index = <NUM_LIT:2> ) <EOL> assert_equal ( len ( list ( splitter ) ) , <NUM_LIT:3> ) <EOL> def _verify_message ( self , splitter , msg = '<STR_LIT:X>' , level = '<STR_LIT>' , html = False , <EOL> timestamp = None , index = <NUM_LIT:0> ) : <EOL> message = list ( splitter ) [ index ] <EOL> assert_equal ( message . message , msg ) <EOL> assert_equal ( message . level , level ) <EOL> assert_equal ( message . html , html ) <EOL> if timestamp : <EOL> assert_equal ( message . timestamp , <EOL> format_time ( timestamp , millissep = '<STR_LIT:.>' ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
