def test_record_mode_bad():
 output = StringIO()
 recorder = Record(file_object=output, replay=False)
 record_mode = RecordMode(recorder)
 i = iscalar()
 f = function([i], i, mode=record_mode, name='f')
 num_lines = 10
 for i in xrange(num_lines):
  recorder.handle_line((str(i) + '\n'))
  f(i)
 output_value = output.getvalue()
 output = StringIO(output_value)
 playback_checker = Record(file_object=output, replay=True)
 playback_mode = RecordMode(playback_checker)
 i = iscalar()
 f = function([i], i, mode=playback_mode, name='f')
 for i in xrange((num_lines // 2)):
  playback_checker.handle_line((str(i) + '\n'))
  f(i)
 try:
  f(0)
 except MismatchError:
  return
 raise AssertionError('Failed to detect a mismatch.')

def test_record_mode_bad ( ) : output = StringIO ( ) recorder = Record ( file_object = output , replay = False ) record_mode = RecordMode ( recorder ) i = iscalar ( ) f = function ( [ i ] , i , mode = record_mode , name = 'f' ) num_lines = 10 for i in xrange ( num_lines ) : recorder . handle_line ( ( str ( i ) + '\n' ) ) f ( i ) output_value = output . getvalue ( ) output = StringIO ( output_value ) playback_checker = Record ( file_object = output , replay = True ) playback_mode = RecordMode ( playback_checker ) i = iscalar ( ) f = function ( [ i ] , i , mode = playback_mode , name = 'f' ) for i in xrange ( ( num_lines // 2 ) ) : playback_checker . handle_line ( ( str ( i ) + '\n' ) ) f ( i ) try : f ( 0 ) except MismatchError : return raise AssertionError ( 'Failed to detect a mismatch.' )
like test_record_bad .