Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@michaelaye
Created June 11, 2014 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelaye/65d6e63b018a01283848 to your computer and use it in GitHub Desktop.
Save michaelaye/65d6e63b018a01283848 to your computer and use it in GitHub Desktop.
pytest_bdd failure output
$ py.test
================================================ test session starts =================================================
platform darwin -- Python 2.7.7 -- py-1.4.20 -- pytest-2.5.2
plugins: bdd
collected 1 items
test_zero.py F
====================================================== FAILURES ======================================================
___________________________________________________ test_zero[0-1] ___________________________________________________
number = 0, out = 1, request = <FixtureRequest for <Function 'test_zero[0-1]'>>
example_converters=dict(number=int, out=int))
> def test_zero():
pass
test_zero.py:6:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
feature = <pytest_bdd.feature.Feature object at 0x103336d50>
scenario = <pytest_bdd.feature.Scenario object at 0x103336e50>
request = <FixtureRequest for <Function 'test_zero[0-1]'>>, encoding = 'utf-8', example = None
def _execute_scenario(feature, scenario, request, encoding, example=None):
"""Execute the scenario."""
givens = set()
# Execute scenario steps
for step in scenario.steps:
try:
step_func = _find_step_function(request, step, encoding=encoding)
except exceptions.StepDefinitionNotFoundError as exception:
request.config.hook.pytest_bdd_step_func_lookup_error(
request=request, feature=feature, scenario=scenario, step=step, exception=exception)
raise
try:
# Check the step types are called in the correct order
if step_func.step_type != step.type:
raise exceptions.StepTypeError(
'Wrong step type "{0}" while "{1}" is expected.'.format(step_func.step_type, step.type)
)
# Check if the fixture that implements given step has not been yet used by another given step
if step.type == GIVEN:
if step_func.fixture in givens:
raise exceptions.GivenAlreadyUsed(
'Fixture "{0}" that implements this "{1}" given step has been already used.'.format(
step_func.fixture, step.name,
)
)
givens.add(step_func.fixture)
except exceptions.ScenarioValidationError as exception:
request.config.hook.pytest_bdd_step_validation_error(
request=request, feature=feature, scenario=scenario, step=step, step_func=step_func,
exception=exception)
raise
> _execute_step_function(request, feature, step, step_func, example=example)
../../anaconda/lib/python2.7/site-packages/pytest_bdd/scenario.py:170:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <FixtureRequest for <Function 'test_zero[0-1]'>>
feature = <pytest_bdd.feature.Feature object at 0x103336d50>, step = <pytest_bdd.feature.Step object at 0x103336f10>
step_func = <function I see the number <out> at 0x10334f230>, example = None
def _execute_step_function(request, feature, step, step_func, example=None):
"""Execute step function."""
kwargs = {}
if example:
for key in step.params:
value = example[key]
if step_func.converters and key in step_func.converters:
value = step_func.converters[key](value)
_inject_fixture(request, key, value)
try:
# Get the step argument values
kwargs = dict((arg, request.getfuncargvalue(arg)) for arg in inspect.getargspec(step_func).args)
request.config.hook.pytest_bdd_before_step(
request=request, feature=feature, scenario=scenario, step=step, step_func=step_func,
step_func_args=kwargs)
# Execute the step
> step_func(**kwargs)
../../anaconda/lib/python2.7/site-packages/pytest_bdd/scenario.py:124:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
have_number = {'computed': -1, 'number': 0}, out = 1
@then('I see the number <out>')
def check_number(have_number, out):
assert isinstance(out, int)
> assert have_number['computed'] == out
E assert -1 == 1
test_zero.py:24: AssertionError
============================================== 1 failed in 0.02 seconds ==============================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment