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

[Bug]: pytest_terminal_summary reports incorrect test suite timing numbers #467

Open
agriyakhetarpal opened this issue Aug 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@agriyakhetarpal
Copy link
Member

Python Version

3.X

Describe the bug

The following code block in conftest.py is trying to calculate the number of tests and the time taken to finish the test suite:

def pytest_terminal_summary(terminalreporter, exitstatus, config):
    """Add additional section to terminal summary reporting."""
    total_time = sum([x.duration for x in terminalreporter.stats.get("passed", [])])
    num_tests = len(terminalreporter.stats.get("passed", []))
    print(f"\nTotal number of tests completed: {num_tests}")
    print(f"Total time taken: {total_time:.2f} seconds")

However, its numbers are way off. For example, running the unit nox session reports that 219 tests were completed in 58.71 seconds, but pytest itself mentions that it finished up in 17.06 seconds, and the pytest reportage is correct.

Steps to reproduce the behaviour

A minimal reproducer is as follows:

python3.X -m virtualenv venv
source venv/bin/activate
python -m pip install pybop[dev]
nox -s unit

Truncated logs are available below.

Relevant log output

Total number of tests completed: 219
Total time taken: 61.36 seconds
============================================================= 219 passed, 228 skipped, 1690 warnings in 17.33s ==============================================================
nox > Session unit was successful.
@agriyakhetarpal agriyakhetarpal added the bug Something isn't working label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant