def assert_dict_contains(test_case, expected, actual, message=''):
 missing_items = []
 mismatch_items = []
 no_value = object()
 for (key, expected_value) in expected.items():
  actual_value = actual.get(key, no_value)
  if (actual_value is no_value):
   missing_items.append(key)
  elif (actual_value != expected_value):
   mismatch_items.append('{}: {} != {}'.format(key, expected_value, actual_value))
 if (missing_items or mismatch_items):
  test_case.fail('{}\nMissing items: {}\nMismatch items:  {}\nActual items: {}'.format(message, missing_items, mismatch_items, actual))

def assert_dict_contains ( test_case , expected , actual , message = '' ) : missing_items = [ ] mismatch_items = [ ] no_value = object ( ) for ( key , expected_value ) in expected . items ( ) : actual_value = actual . get ( key , no_value ) if ( actual_value is no_value ) : missing_items . append ( key ) elif ( actual_value != expected_value ) : mismatch_items . append ( '{}: {} != {}' . format ( key , expected_value , actual_value ) ) if ( missing_items or mismatch_items ) : test_case . fail ( '{}\nMissing items: {}\nMismatch items:  {}\nActual items: {}' . format ( message , missing_items , mismatch_items , actual ) )
fail unless the supplied actual dict contains all the items in expected .