Skip to content

Commit

Permalink
refactor(compare): disable maxDiff length limit while comparing values
Browse files Browse the repository at this point in the history
  • Loading branch information
h2non committed Apr 3, 2017
1 parent 4617b6c commit ac3d3f7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pook/assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
PY_3 = sys.version_info >= (3,)


def test_case():
"""
Creates a new ``unittest.TestCase`` instance.
Returns:
unittest.TestCase
"""
test = TestCase()
test.maxDiff = None
return test


def equal(x, y):
"""
Shortcut function for ``unittest.TestCase.assertEqual()``.
Expand All @@ -22,7 +34,7 @@ def equal(x, y):
bool
"""
if PY_3:
return TestCase().assertEqual(x, y) or True
return test_case().assertEqual(x, y) or True

assert x == y

Expand Down Expand Up @@ -51,7 +63,7 @@ def matches(x, y, regex_expr=False):
# Retrieve original regex pattern
x = x.pattern if isregex(x) else x
# Assert regular expression via unittest matchers
return TestCase().assertRegexpMatches(y, x) or True
return test_case().assertRegexpMatches(y, x) or True

# Primitive regex matching for Python 2.7
if isinstance(x, str):
Expand Down

0 comments on commit ac3d3f7

Please sign in to comment.