<s> from pytest import raises <EOL> from remoto import log <EOL> from remoto . exc import TimeoutError <EOL> from mock import Mock <EOL> class TestReporting ( object ) : <EOL> def test_reporting_when_channel_is_empty ( self ) : <EOL> conn = Mock ( ) <EOL> result = Mock ( ) <EOL> result . receive . side_effect = EOFError <EOL> log . reporting ( conn , result ) <EOL> def test_write_debug_statements ( self ) : <EOL> conn = Mock ( ) <EOL> result = Mock ( ) <EOL> result . receive . side_effect = [ { '<STR_LIT>' : '<STR_LIT>' } , EOFError ] <EOL> log . reporting ( conn , result ) <EOL> assert conn . logger . debug . called is True <EOL> assert conn . logger . info . called is False <EOL> def test_write_info_statements ( self ) : <EOL> conn = Mock ( ) <EOL> result = Mock ( ) <EOL> result . receive . side_effect = [ { '<STR_LIT:error>' : '<STR_LIT>' } , EOFError ] <EOL> log . reporting ( conn , result ) <EOL> assert conn . logger . debug . called is False <EOL> assert conn . logger . error . called is True <EOL> def test_strip_new_lines ( self ) : <EOL> conn = Mock ( ) <EOL> result = Mock ( ) <EOL> result . receive . side_effect = [ { '<STR_LIT:error>' : '<STR_LIT>' } , EOFError ] <EOL> log . reporting ( conn , result ) <EOL> message = conn . logger . error . call_args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> assert message == '<STR_LIT>' <EOL> def test_timeout_error ( self ) : <EOL> conn = Mock ( ) <EOL> result = Mock ( ) <EOL> result . receive . side_effect = TimeoutError <EOL> log . reporting ( conn , result ) <EOL> message = conn . logger . warning . call_args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> assert '<STR_LIT>' in message <EOL> def test_raises_other_errors ( self ) : <EOL> conn = Mock ( ) <EOL> result = Mock ( ) <EOL> result . receive . side_effect = OSError <EOL> with raises ( OSError ) : <EOL> log . reporting ( conn , result ) </s>
