Created
June 8, 2015 03:00
-
-
Save curzona/8c7c8b254b7c9417d265 to your computer and use it in GitHub Desktop.
pytest-bdd output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| py.test -l --tb=long | |
| =========================== test session starts =========================== | |
| platform linux2 -- Python 2.7.6 -- py-1.4.26 -- pytest-2.6.4 | |
| plugins: ordering, bdd, instafail, cov, xdist | |
| collected 1 items | |
| test_bdd.py F | |
| ================================ FAILURES ================================= | |
| _________________ test_SomeDeterminableBusinessSituation __________________ | |
| request = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| @scenario('bdd.feature', 'Some determinable business situation') | |
| > def test_SomeDeterminableBusinessSituation(): | |
| print 'test_SomeDeterminableBusinessSituation' | |
| request = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| test_bdd.py:4: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| feature = <pytest_bdd.feature.Feature object at 0x7fbe8baebc10> | |
| scenario = <pytest_bdd.feature.Scenario object at 0x7fbe8bb0d810> | |
| request = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| encoding = 'utf-8', example = None | |
| def _execute_scenario(feature, scenario, request, encoding, example=None): | |
| """Execute the scenario. | |
| :param feature: Feature. | |
| :param scenario: Scenario. | |
| :param request: request. | |
| :param encoding: Encoding. | |
| :param example: Example. | |
| """ | |
| request.config.hook.pytest_bdd_before_scenario( | |
| request=request, | |
| feature=feature, | |
| scenario=scenario, | |
| ) | |
| try: | |
| givens = set() | |
| # Execute scenario steps | |
| for step in scenario.steps: | |
| try: | |
| step_func = _find_step_function(request, step, scenario, 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( | |
| u'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, scenario, step, step_func, example=example) | |
| encoding = 'utf-8' | |
| example = None | |
| feature = <pytest_bdd.feature.Feature object at 0x7fbe8baebc10> | |
| givens = set(['some_precondition']) | |
| request = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| scenario = <pytest_bdd.feature.Scenario object at 0x7fbe8bb0d810> | |
| step = <pytest_bdd.feature.Step object at 0x7fbe8bb0d850> | |
| step_func = <function some precondition at 0x7fbe8bb07848> | |
| /usr/local/lib/python2.7/dist-packages/pytest_bdd/scenario.py:237: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| request = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| scenario = <pytest_bdd.feature.Scenario object at 0x7fbe8bb0d810> | |
| step = <pytest_bdd.feature.Step object at 0x7fbe8bb0d850> | |
| step_func = <function some precondition at 0x7fbe8bb07848>, example = None | |
| def _execute_step_function(request, scenario, step, step_func, example=None): | |
| """Execute step function. | |
| :param request: PyTest request. | |
| :param scenario: Scenario. | |
| :param step: Step. | |
| :param function step_func: Step function. | |
| :param example: Example table. | |
| """ | |
| request.config.hook.pytest_bdd_before_step( | |
| request=request, | |
| feature=scenario.feature, | |
| scenario=scenario, | |
| step=step, | |
| step_func=step_func, | |
| ) | |
| 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) | |
| kw = dict( | |
| request=request, | |
| feature=scenario.feature, | |
| scenario=scenario, | |
| step=step, | |
| step_func=step_func, | |
| step_func_args=kwargs, | |
| ) | |
| try: | |
| # Get the step argument values. | |
| kwargs = dict((arg, request.getfuncargvalue(arg)) for arg in inspect.getargspec(step_func).args) | |
| # Execute the step. | |
| > step_func(**kwargs) | |
| example = None | |
| exception = AssertionError(u'assert False',) | |
| kw = {'feature': <pytest_bdd.feature.Feature object at 0x7fbe8baebc10>, 'request': <FixtureRequest for <Function 'test_Some...pytest_bdd.feature.Scenario object at 0x7fbe8bb0d810>, 'step': <pytest_bdd.feature.Step object at 0x7fbe8bb0d850>, ...} | |
| kwargs = {'request': <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>>} | |
| request = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| scenario = <pytest_bdd.feature.Scenario object at 0x7fbe8bb0d810> | |
| step = <pytest_bdd.feature.Step object at 0x7fbe8bb0d850> | |
| step_func = <function some precondition at 0x7fbe8bb07848> | |
| /usr/local/lib/python2.7/dist-packages/pytest_bdd/scenario.py:171: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| request = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| > step_func = lambda request: request.getfuncargvalue(func.__name__) | |
| func = <function some_precondition at 0x7fbe8bb078c0> | |
| request = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| /usr/local/lib/python2.7/dist-packages/pytest_bdd/steps.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| argname = 'some_precondition' | |
| def getfuncargvalue(self, argname): | |
| """ Dynamically retrieve a named fixture function argument. | |
| As of pytest-2.3, it is easier and usually better to access other | |
| fixture values by stating it as an input argument in the fixture | |
| function. If you only can decide about using another fixture at test | |
| setup time, you may use this function to retrieve it inside a fixture | |
| function body. | |
| """ | |
| > return self._get_active_fixturedef(argname).cached_result[0] | |
| argname = 'some_precondition' | |
| self = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| /usr/local/lib/python2.7/dist-packages/_pytest/python.py:1337: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| argname = 'some_precondition' | |
| def _get_active_fixturedef(self, argname): | |
| try: | |
| return self._fixturedefs[argname] | |
| except KeyError: | |
| try: | |
| fixturedef = self._getnextfixturedef(argname) | |
| except FixtureLookupError: | |
| if argname == "request": | |
| class PseudoFixtureDef: | |
| cached_result = (self, [0], None) | |
| return PseudoFixtureDef | |
| raise | |
| > result = self._getfuncargvalue(fixturedef) | |
| argname = 'some_precondition' | |
| fixturedef = <FixtureDef name='some_precondition' scope='function' baseid='test_bdd.py' > | |
| self = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| /usr/local/lib/python2.7/dist-packages/_pytest/python.py:1351: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| fixturedef = <FixtureDef name='some_precondition' scope='function' baseid='test_bdd.py' > | |
| def _getfuncargvalue(self, fixturedef): | |
| # prepare a subrequest object before calling fixture function | |
| # (latter managed by fixturedef) | |
| argname = fixturedef.argname | |
| funcitem = self._pyfuncitem | |
| scope = fixturedef.scope | |
| try: | |
| param = funcitem.callspec.getparam(argname) | |
| except (AttributeError, ValueError): | |
| param = NOTSET | |
| param_index = 0 | |
| else: | |
| # indices might not be set if old-style metafunc.addcall() was used | |
| param_index = funcitem.callspec.indices.get(argname, 0) | |
| # if a parametrize invocation set a scope it will override | |
| # the static scope defined with the fixture function | |
| paramscopenum = funcitem.callspec._arg2scopenum.get(argname) | |
| if paramscopenum is not None: | |
| scope = scopes[paramscopenum] | |
| subrequest = SubRequest(self, scope, param, param_index, fixturedef) | |
| # check if a higher-level scoped fixture accesses a lower level one | |
| if scope is not None: | |
| __tracebackhide__ = True | |
| if scopemismatch(self.scope, scope): | |
| # try to report something helpful | |
| lines = subrequest._factorytraceback() | |
| raise ScopeMismatchError("You tried to access the %r scoped " | |
| "fixture %r with a %r scoped request object, " | |
| "involved factories\n%s" %( | |
| (scope, argname, self.scope, "\n".join(lines)))) | |
| __tracebackhide__ = False | |
| try: | |
| # call the fixture function | |
| > val = fixturedef.execute(request=subrequest) | |
| __tracebackhide__ = False | |
| argname = 'some_precondition' | |
| fixturedef = <FixtureDef name='some_precondition' scope='function' baseid='test_bdd.py' > | |
| funcitem = <Function 'test_SomeDeterminableBusinessSituation'> | |
| param = <object object at 0x7fbe8ee190c0> | |
| param_index = 0 | |
| scope = 'function' | |
| self = <FixtureRequest for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| subrequest = <SubRequest 'some_precondition' for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| /usr/local/lib/python2.7/dist-packages/_pytest/python.py:1403: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FixtureDef name='some_precondition' scope='function' baseid='test_bdd.py' > | |
| request = <SubRequest 'some_precondition' for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| def execute(self, request): | |
| # get required arguments and register our own finish() | |
| # with their finalization | |
| kwargs = {} | |
| for argname in self.argnames: | |
| fixturedef = request._get_active_fixturedef(argname) | |
| result, arg_cache_key, exc = fixturedef.cached_result | |
| kwargs[argname] = result | |
| if argname != "request": | |
| fixturedef.addfinalizer(self.finish) | |
| my_cache_key = request.param_index | |
| cached_result = getattr(self, "cached_result", None) | |
| if cached_result is not None: | |
| result, cache_key, err = cached_result | |
| if my_cache_key == cache_key: | |
| if err is not None: | |
| py.builtin._reraise(*err) | |
| else: | |
| return result | |
| # we have a previous but differently parametrized fixture instance | |
| # so we need to tear it down before creating a new one | |
| self.finish() | |
| assert not hasattr(self, "cached_result") | |
| if self.unittest: | |
| result = self.func(request.instance, **kwargs) | |
| else: | |
| fixturefunc = self.func | |
| # the fixture function needs to be bound to the actual | |
| # request.instance so that code working with "self" behaves | |
| # as expected. | |
| if request.instance is not None: | |
| fixturefunc = getimfunc(self.func) | |
| if fixturefunc != self.func: | |
| fixturefunc = fixturefunc.__get__(request.instance) | |
| try: | |
| result = call_fixture_func(fixturefunc, request, kwargs, | |
| > self.yieldctx) | |
| cached_result = None | |
| fixturefunc = <function some_precondition at 0x7fbe8bb078c0> | |
| kwargs = {} | |
| my_cache_key = 0 | |
| request = <SubRequest 'some_precondition' for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| self = <FixtureDef name='some_precondition' scope='function' baseid='test_bdd.py' > | |
| /usr/local/lib/python2.7/dist-packages/_pytest/python.py:1858: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| fixturefunc = <function some_precondition at 0x7fbe8bb078c0> | |
| request = <SubRequest 'some_precondition' for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| kwargs = {}, yieldctx = False | |
| def call_fixture_func(fixturefunc, request, kwargs, yieldctx): | |
| if yieldctx: | |
| if not is_generator(fixturefunc): | |
| fail_fixturefunc(fixturefunc, | |
| msg="yield_fixture requires yield statement in function") | |
| iter = fixturefunc(**kwargs) | |
| next = getattr(iter, "__next__", None) | |
| if next is None: | |
| next = getattr(iter, "next") | |
| res = next() | |
| def teardown(): | |
| try: | |
| next() | |
| except StopIteration: | |
| pass | |
| else: | |
| fail_fixturefunc(fixturefunc, | |
| "yield_fixture function has more than one 'yield'") | |
| request.addfinalizer(teardown) | |
| else: | |
| if is_generator(fixturefunc): | |
| fail_fixturefunc(fixturefunc, | |
| msg="pytest.fixture functions cannot use ``yield``. " | |
| "Instead write and return an inner function/generator " | |
| "and let the consumer call and iterate over it.") | |
| > res = fixturefunc(**kwargs) | |
| fixturefunc = <function some_precondition at 0x7fbe8bb078c0> | |
| kwargs = {} | |
| request = <SubRequest 'some_precondition' for <Function 'test_SomeDeterminableBusinessSituation'>> | |
| yieldctx = False | |
| /usr/local/lib/python2.7/dist-packages/_pytest/python.py:1784: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| @given('some precondition') | |
| def some_precondition(): | |
| print 'some_precondition' | |
| > assert False | |
| E assert False | |
| test_bdd.py:10: AssertionError | |
| -------------------------- Captured stdout call --------------------------- | |
| some_precondition | |
| ======================== 1 failed in 0.06 seconds ========================= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| py.test -l --tb=long | |
| ============================= test session starts ============================== | |
| platform linux2 -- Python 2.7.6 -- py-1.4.26 -- pytest-2.6.4 | |
| plugins: ordering, bdd, instafail, cov, xdist | |
| collected 1 items | |
| Some determinable business situation FAILED | |
| =================================== FAILURES =================================== | |
| _____________________ Some determinable business situation _____________________ | |
| Scenario: Some determinable business situation | |
| > Given some precondition | |
| And some other precondition | |
| When some action by the actor | |
| And some other action | |
| And yet another action | |
| Then some testable outcome is achieved | |
| And something else we can check happens too | |
| bdd.feature:2: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| @given('some precondition') | |
| def some_precondition(): | |
| print 'some_precondition' | |
| > assert False | |
| E assert False | |
| test_bdd.py:10: AssertionError | |
| ----------------------------- Captured stdout call ----------------------------- | |
| some_precondition | |
| =========================== 1 failed in 0.06 seconds =========================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment