Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parametrized session-scoped fixtures: KeyError in logger #39

Closed
i-feofilaktov opened this issue Feb 10, 2017 · 0 comments
Closed

Parametrized session-scoped fixtures: KeyError in logger #39

i-feofilaktov opened this issue Feb 10, 2017 · 0 comments
Assignees

Comments

@i-feofilaktov
Copy link
Contributor

Reproducing:

import pytest

@pytest.fixture(scope='session', params=['param a'])
def param(request):
    return request.param

def test_smth(param):
    with pytest.allure.step('Test {}'.format(param)):
        assert param == 'param a'

Trace:

$ py.test test.py --alluredir allure-results/
============================================================================================================ test session starts =============================================================================================================
platform linux -- Python 3.4.5, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /home/igorock/Work/backend-tests, inifile: 
plugins: timeout-1.2.0, allure-adaptor-2.0.1
collected 1 items 

test.py E

=================================================================================================================== ERRORS ===================================================================================================================
____________________________________________________________________________________________________ ERROR at setup of test_smth[param b] ____________________________________________________________________________________________________

self = <allure.listener.AllureListener object at 0x7fee15ef7c50>, fixturedef = <FixtureDef name='param' scope='session' baseid='test.py' >, request = <SubRequest 'param' for <Function 'test_smth[param b]'>>

    @pytest.hookimpl(hookwrapper=True)
    def pytest_fixture_setup(self, fixturedef, request):
        uuid = uuid4()
        node_id = request.node.nodeid
        parent_uuid = self._cache.get(node_id) if fixturedef.scope == 'function' else self._cache.get(fixturedef)
        parameters = allure_parameters(fixturedef, request)
    
        # ToDo autouse fixtures
        if fixturedef.baseid and parent_uuid:
            fixture = ExecutableItem(start=now(), name=fixturedef.argname)
            self.allure_logger.start_before_fixture(parent_uuid, uuid, fixture)
    
        if parameters and parent_uuid:
            parameters = Parameter(**parameters) if parameters else []
>           self.allure_logger.update_test(self._cache.get(node_id), parameters=parameters)

/usr/lib/python3.4/site-packages/allure/listener.py:95: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.4/site-packages/allure/logger.py:57: in update_test
    self._update_item(uuid, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <allure.logger.AllureLogger object at 0x7fee15ef7c88>, uuid = None, kwargs = {'parameters': Parameter(name='param', value='param b')}

    def _update_item(self, uuid, **kwargs):
>       item = self._items[uuid]
E       KeyError: None

/usr/lib/python3.4/site-packages/allure/logger.py:18: KeyError
========================================================================================================== 1 error in 0.05 seconds ===========================================================================================================

Environment:

$ sudo pip freeze | grep pytest 
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pytest==3.0.6
pytest-allure-adaptor==2.0.1
pytest-timeout==1.2.0

P.S. allure-python2 was updated 2017.02.10 at 16:24 MSK :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants