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

pytest_sessionfinish is called before log file is created #9770

Open
ghost opened this issue Mar 15, 2022 · 0 comments
Open

pytest_sessionfinish is called before log file is created #9770

ghost opened this issue Mar 15, 2022 · 0 comments
Labels
plugin: logging related to the logging builtin plugin

Comments

@ghost
Copy link

ghost commented Mar 15, 2022

Pytest v7.0.1
pytest_sessionfinish function is called before log file is created, which seems incorrect.
To reproduce:

  1. Setup logging to fine in pytest.ini:
log_file = report/allure-report/tests.log
log_file_date_format = %Y-%m-%d %H:%M:%S
log_file_level = INFO
  1. Create pytest_sessionfinish function in conftest.py, which will interact with log file (e.g. create an archive with test report)
def pytest_sessionfinish(session, exitstatus):
    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)

As a result, there'll be no tests.log file in this archive.

@Zac-HD Zac-HD added the plugin: logging related to the logging builtin plugin label Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: logging related to the logging builtin plugin
Projects
None yet
Development

No branches or pull requests

1 participant