inveniosoftware / pytest-invenio

Pytest fixtures for Invenio.
https://pytest-invenio.readthedocs.io
Other
3 stars 22 forks source link

bug: scope fix for pytest 3.8.1 #19

Closed fenekku closed 5 years ago

fenekku commented 5 years ago

Hello,

pytest 3.8.1 fixed some scoping issues, but this caused

def pytest_generate_tests(metafunc):
    # ...
    metafunc.parametrize('browser', browsers, indirect=True)

to generate a session scoped parametrized test. The following hook

@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):

was then just run once the session was torndown (or at least not at the right moment).

def _take_screenshot_if_test_failed(browser, request): ...

would throw AttributeError: 'Session' object has no attribute 'rep_call' because item was never set the rep.

Long story short, metafunc.parametrize('browser', browsers, indirect=True, scope='function') fixes it.

Side note, the test suite is broken for Elasticsearch 6.

ntarocco commented 5 years ago

LGTM! Thank you for your contribution!

ntarocco commented 5 years ago

Actually, could you please remove the version change in your commit? We are going to release it just after merging the other PR that is open.

fenekku commented 5 years ago

Done! :+1: