to better match the naming of the corresponding AST (and in case
we want to add more customizations later) rename pytest_assert_binrepr -> pytest_assertrepr_compare rename binrepr -> reprcompare --HG-- branch : trunk
This commit is contained in:
@@ -15,20 +15,20 @@ def pytest_configure(config):
|
||||
if not config.getvalue("noassert") and not config.getvalue("nomagic"):
|
||||
warn_about_missing_assertion()
|
||||
config._oldassertion = py.builtin.builtins.AssertionError
|
||||
config._oldbinrepr = py.code._binrepr
|
||||
config._oldbinrepr = py.code._reprcompare
|
||||
py.builtin.builtins.AssertionError = py.code._AssertionError
|
||||
def callbinrepr(op, left, right):
|
||||
hook_result = config.hook.pytest_assert_binrepr(
|
||||
hook_result = config.hook.pytest_assertrepr_compare(
|
||||
config=config, op=op, left=left, right=right)
|
||||
for new_expl in hook_result:
|
||||
if new_expl:
|
||||
return '\n~'.join(new_expl)
|
||||
py.code._binrepr = callbinrepr
|
||||
py.code._reprcompare = callbinrepr
|
||||
|
||||
def pytest_unconfigure(config):
|
||||
if hasattr(config, '_oldassertion'):
|
||||
py.builtin.builtins.AssertionError = config._oldassertion
|
||||
py.code._binrepr = config._oldbinrepr
|
||||
py.code._reprcompare = config._oldbinrepr
|
||||
del config._oldassertion
|
||||
del config._oldbinrepr
|
||||
|
||||
@@ -49,8 +49,8 @@ except NameError:
|
||||
basestring = str
|
||||
|
||||
|
||||
def pytest_assert_binrepr(op, left, right):
|
||||
"""Make specialised explanations for some operators/operands"""
|
||||
def pytest_assertrepr_compare(op, left, right):
|
||||
"""return specialised explanations for some operators/operands"""
|
||||
left_repr = py.io.saferepr(left, maxsize=30)
|
||||
right_repr = py.io.saferepr(right, maxsize=30)
|
||||
summary = '%s %s %s' % (left_repr, op, right_repr)
|
||||
|
||||
Reference in New Issue
Block a user