Skip to content

Commit

Permalink
[#1117] Move some test comments into asserts
Browse files Browse the repository at this point in the history
This makes the output when tests fail more useful

Unfortunately I don't see how to do this with assert_raises.
  • Loading branch information
Sean Hammond committed Jul 25, 2013
1 parent 854407a commit ed12fa0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions ckan/new_tests/lib/navl/test_validators.py
Expand Up @@ -58,20 +58,22 @@ def test_ignore_missing_with_value_missing(self):
original_errors = copy.deepcopy(errors)

with nose.tools.assert_raises(df.StopOnError):
validators.ignore_missing(
key=key,
data=data,
errors=errors,
context={})

# ignore_missing() should remove the key being validated from the
# data dict, but it should not remove other keys or add any keys.
validators.ignore_missing(key=key, data=data, errors=errors,
context={})

assert key not in data, ('When given a value of {value} '
'ignore_missing() should remove the item from the data '
'dict'.format(value=value))

if key in original_data:
del original_data[key]
assert data == original_data
assert data == original_data, ('When given a value of {value} '
'ignore_missing() should not modify other items in the '
'data dict'.format(value=value))

# ignore_missing() shouldn't modify the errors dict.
assert errors == original_errors
assert errors == original_errors, ('When given a value of {value} '
'ignore_missing should not modify the errors dict'.format(
value=value))

def test_ignore_missing_with_a_value(self):
'''If data[key] is neither None or missing, ignore_missing() should do
Expand Down

0 comments on commit ed12fa0

Please sign in to comment.