Skip to content

Commit

Permalink
more pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
awestendorf committed May 6, 2014
1 parent 97977fe commit 4c721d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion chai/comparators.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def test(self, value):
return round(value - self._float_value, self._places) == 0

def __repr__(self):
return "AlmostEqual(value: %s, places: %d)" % (str(self._float_value), self._places)
return "AlmostEqual(value: %s, places: %d)" % (
str(self._float_value), self._places)
__str__ = __repr__


Expand Down
17 changes: 11 additions & 6 deletions chai/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

def pretty_format_args(*args, **kwargs):
"""
Take the args, and kwargs that are passed them and format in a prototype style.
Take the args, and kwargs that are passed them and format in a
prototype style.
"""
args = list([repr(a) for a in args])
for key, value in kwargs.items():
Expand Down Expand Up @@ -50,7 +51,9 @@ class UnexpectedCall(BaseException):
Raised when a unexpected call occurs to a stub.
'''

def __init__(self, msg=None, prefix=None, suffix=None, call=None, args=None, kwargs=None, expected_args=None, expected_kwargs=None):
def __init__(self, msg=None, prefix=None, suffix=None, call=None,
args=None, kwargs=None, expected_args=None,
expected_kwargs=None):
if msg:
msg = colored('\n\n' + msg.strip(), 'red')
else:
Expand All @@ -69,14 +72,16 @@ def __init__(self, msg=None, prefix=None, suffix=None, call=None, args=None, kwa
if expected_args or expected_kwargs:
msg += colored('\n\nExpected\n', 'white', attrs=['bold'])
msg += colored(call, 'red')
msg += colored(pretty_format_args(*(expected_args or ()),
**(expected_kwargs or {})), 'red')
msg += colored(pretty_format_args(
*(expected_args or ()),
**(expected_kwargs or {})), 'red')

# If handling an exception, add printing of it here.
if sys.exc_info()[0]:
msg += colored('\n\nWhile handling\n', 'white', attrs=['bold'])
msg += colored(''.join(traceback.format_exception(*
sys.exc_info())), 'red')
msg += colored(''.join(
traceback.format_exception(*sys.exc_info())),
'red')

if suffix:
msg = msg + '\n\n' + suffix.strip()
Expand Down

0 comments on commit 4c721d0

Please sign in to comment.