def does_not_modify_errors_dict(validator):
 def call_and_assert(key, data, errors, context=None):
  if (context is None):
   context = {}
  original_data = copy.deepcopy(data)
  original_errors = copy.deepcopy(errors)
  original_context = copy.deepcopy(context)
  result = validator(key, data, errors, context=context)
  assert (errors == original_errors), 'Should not modify errors dict when called with key: {key}, data: {data}, errors: {errors}, context: {context}'.format(key=key, data=original_data, errors=original_errors, context=original_context)
  return result
 return call_and_assert

def does_not_modify_errors_dict ( validator ) : def call_and_assert ( key , data , errors , context = None ) : if ( context is None ) : context = { } original_data = copy . deepcopy ( data ) original_errors = copy . deepcopy ( errors ) original_context = copy . deepcopy ( context ) result = validator ( key , data , errors , context = context ) assert ( errors == original_errors ) , 'Should not modify errors dict when called with key: {key}, data: {data}, errors: {errors}, context: {context}' . format ( key = key , data = original_data , errors = original_errors , context = original_context ) return result return call_and_assert
a decorator that asserts that the decorated validator doesnt modify its errors dict param .