'How to collect pytest allure report after the test session?

I'm using Allure + Pytest for tests execution. Right now I need to archive tests results, but I'm facing the fact that archive is created before the test run is finished. I've tried to call pytest_sessionfinish, but archive is created before tests.log file is created:

pytest.ini content: log_file = report/allure-report/tests.log

    def pytest_sessionfinish(session, exitstatus):
        # Fixme, use https://docs.pytest.org/en/latest/reference/reference.html#_pytest.hookspec.pytest_sessionfinish ?
        cmdName = 'tar -C %s -czf %s.tar %s ' % (SETTINGS.paths.report, basename(SETTINGS.paths.timestamp), SETTINGS.paths.report)
        LOGGER.info('Calling "%s" cmd to get archive' % cmdName)
        call(cmdName)

Also, I've tried to create a fixture with scope='session' and autouse=True, but it's called even before all Allure files are created. Any ideas except creating a runner script, which will call pytest.main() and archive command after it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source