Skip to content

Commit

Permalink
Merge branch 'convert_self.assert_method_calls_to_plain_asserts_#259'
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaiarocci committed Sep 6, 2016
2 parents 3c48c1b + 28ddf6f commit e458699
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 226 deletions.
1 change: 1 addition & 0 deletions .cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Patches and Suggestions
- Arsh Singh
- Brandon Aubie
- Brett
- Bruno Oliveira
- C.D. Clark III
- Damián Nohales
- Danielle Pizzolli
Expand Down
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Changelog

Here you can see the full list of changes between each Cerberus release.

Unreleased
------------

- Convert ``self.assert`` method calls to plain ``assert`` calls supported by
pytest. Addresses #213 (Bruno Oliveira).

Version 1.0.1
-------------

Expand Down
21 changes: 10 additions & 11 deletions cerberus/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def assertException(self, known_exception, document, schema=None,
validator(document, schema)
except known_exception as e:
if msg is not None:
self.assertEqual(str(e), msg)
assert str(e) == msg
except Exception as e: # noqa
self.fail("'%s' raised, expected %s." % (e, known_exception))
else:
Expand All @@ -159,15 +159,14 @@ def assertFail(self, document, schema=None, validator=None, update=False):
""" Tests whether a validation fails. """
if validator is None:
validator = self.validator
self.assertFalse(validator(document, schema, update))
assert not validator(document, schema, update)

def assertSuccess(self, document, schema=None, validator=None,
update=False):
""" Tests whether a validation succeeds. """
if validator is None:
validator = self.validator
self.assertTrue(validator(document, schema, update),
validator.errors)
assert validator(document, schema, update), validator.errors

def assertError(self, d_path, s_path, error, constraint, info=(),
v_errors=None):
Expand All @@ -183,13 +182,13 @@ def assertError(self, d_path, s_path, error, constraint, info=(),
for i, v_error in enumerate(v_errors):
assert isinstance(v_error, errors.ValidationError)
try:
self.assertEqual(v_error.document_path, d_path)
self.assertEqual(v_error.schema_path, s_path)
self.assertEqual(v_error.code, error.code)
self.assertEqual(v_error.rule, error.rule)
self.assertEqual(v_error.constraint, constraint)
assert v_error.document_path == d_path
assert v_error.schema_path == s_path
assert v_error.code == error.code
assert v_error.rule == error.rule
assert v_error.constraint == constraint
if not v_error.is_group_error:
self.assertEqual(v_error.info, info)
assert v_error.info == info
except AssertionError:
pass
except Exception as e:
Expand Down Expand Up @@ -249,4 +248,4 @@ def assertNormalized(self, document, expected, schema=None, validator=None):
validator = self.validator

self.assertSuccess(document, schema, validator)
self.assertDictEqual(validator.document, expected)
assert validator.document == expected

0 comments on commit e458699

Please sign in to comment.