<s> import mock <EOL> import sys <EOL> import goless <EOL> from goless . backends import current as be <EOL> from . import BaseTests <EOL> class GoTests ( BaseTests ) : <EOL> def setUp ( self ) : <EOL> BaseTests . setUp ( self ) <EOL> oldpanic = goless . on_panic <EOL> self . panic_calls = [ ] <EOL> goless . on_panic = lambda * a : self . panic_calls . append ( a ) <EOL> def restore_panic ( ) : <EOL> goless . on_panic = oldpanic <EOL> self . addCleanup ( restore_panic ) <EOL> self . addCleanup ( be . yield_ ) <EOL> def test_starts_stuff ( self ) : <EOL> items = [ ] <EOL> goless . go ( lambda : items . append ( <NUM_LIT:1> ) ) <EOL> be . yield_ ( ) <EOL> self . assertEqual ( items , [ <NUM_LIT:1> ] ) <EOL> def test_starts_with_params ( self ) : <EOL> called = mock . Mock ( ) <EOL> goless . go ( called , <NUM_LIT:10> , a = <NUM_LIT:1> ) <EOL> be . yield_ ( ) <EOL> called . assert_called_once_with ( <NUM_LIT:10> , a = <NUM_LIT:1> ) <EOL> def test_exc ( self ) : <EOL> def raiseit ( ) : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> goless . go ( raiseit ) <EOL> be . yield_ ( ) <EOL> self . assertEqual ( len ( self . panic_calls ) , <NUM_LIT:1> ) <EOL> class PanicTests ( BaseTests ) : <EOL> def test_panic_logs_and_exits ( self ) : <EOL> try : <EOL> assert False <EOL> except AssertionError : <EOL> args = sys . exc_info ( ) <EOL> with mock . patch ( '<STR_LIT>' ) as logmock : <EOL> with self . assertRaises ( SystemExit ) : <EOL> goless . on_panic ( * args ) <EOL> self . assertEqual ( logmock . call_count , <NUM_LIT:1> ) </s>
