Skip to content

Commit

Permalink
fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielfalcao committed Dec 31, 2023
1 parent 6397218 commit 6931ddf
Show file tree
Hide file tree
Showing 3 changed files with 636 additions and 579 deletions.
4 changes: 2 additions & 2 deletions docs/source/assertion-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ Assert the magnitude of objects with ``{X}.should.be.greater_than(Y)`` and ``{Y}
(1).should_not.be.lower_than_or_equal_to(0)
Callables
---------
Testing Callables
-----------------


``callable.when.called_with(arg1, kwarg1=2).should.have.raised(Exception)``
Expand Down
35 changes: 3 additions & 32 deletions sure/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,8 @@
from sure.terminal import red, green, yellow


if six.PY2:
def compat_repr(object_repr):
# compat_repr is designed to return all reprs with leading 'u's
# inserted to make all strings look like unicode strings.
# This makes testing between py2 and py3 much easier.
result = ''
in_quote = False
curr_quote = None
for char in object_repr:
if char in ['"', "'"] and (
not curr_quote or char == curr_quote):
if in_quote:
# Closing quote
curr_quote = None
in_quote = False
else:
# Opening quote
curr_quote = char
result += 'u'
in_quote = True
result += char
return result
else:
def compat_repr(object_repr):
return object_repr
def compat_repr(object_repr):
return object_repr


def _obj_with_safe_repr(obj):
Expand All @@ -60,19 +37,13 @@ def _obj_with_safe_repr(obj):
def safe_repr(val):
try:
if isinstance(val, dict):
# We special case dicts to have a sorted repr. This makes testing
# We special case dicts to have a sorted __repr__. This makes testing
# significantly easier
val = _obj_with_safe_repr(val)
ret = repr(val)
if six.PY2:
ret = ret.decode('utf-8')
except UnicodeEncodeError:
ret = red('a %r that cannot be represented' % type(val))
else:
ret = green(ret)

return ret



text_type_name = six.text_type().__class__.__name__

0 comments on commit 6931ddf

Please sign in to comment.