def assert_equal_steps(test_case, expected, actual):
 expected_steps = getattr(expected, 'steps')
 actual_steps = getattr(actual, 'steps')
 if (None in (expected_steps, actual_steps)):
  test_case.assertEqual(expected, actual)
 else:
  mismatch_steps = []
  missing_steps = []
  index = 0
  for (index, expected_step) in enumerate(expected_steps):
   try:
    actual_step = actual_steps[index]
   except IndexError:
    missing_steps = expected_steps[index:]
    break
   if (expected_step != actual_step):
    mismatch_steps.append('* expected: {} !=\n  actual:   {}'.format(expected_step, actual_step))
  extra_steps = actual_steps[(index + 1):]
  if (mismatch_steps or missing_steps or extra_steps):
   test_case.fail('Step Mismatch\nMismatch:\n{}\nMissing:\n{}\nExtra:\n{}'.format('\n'.join(mismatch_steps), missing_steps, extra_steps))

def assert_equal_steps ( test_case , expected , actual ) : expected_steps = getattr ( expected , 'steps' ) actual_steps = getattr ( actual , 'steps' ) if ( None in ( expected_steps , actual_steps ) ) : test_case . assertEqual ( expected , actual ) else : mismatch_steps = [ ] missing_steps = [ ] index = 0 for ( index , expected_step ) in enumerate ( expected_steps ) : try : actual_step = actual_steps [ index ] except IndexError : missing_steps = expected_steps [ index : ] break if ( expected_step != actual_step ) : mismatch_steps . append ( '* expected: {} !=\n  actual:   {}' . format ( expected_step , actual_step ) ) extra_steps = actual_steps [ ( index + 1 ) : ] if ( mismatch_steps or missing_steps or extra_steps ) : test_case . fail ( 'Step Mismatch\nMismatch:\n{}\nMissing:\n{}\nExtra:\n{}' . format ( '\n' . join ( mismatch_steps ) , missing_steps , extra_steps ) )
assert that the list of provided steps are the same .