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

Wrong outcome when test fails #64

Closed
DavideCanton opened this issue Aug 24, 2024 · 0 comments · Fixed by #65
Closed

Wrong outcome when test fails #64

DavideCanton opened this issue Aug 24, 2024 · 0 comments · Fixed by #65

Comments

@DavideCanton
Copy link
Contributor

It seems that the plugin doesn't log the test outcome but the teardown one.

For example, this file:

import pytest


@pytest.mark.parametrize("n", [1, 2, 3])
def test_name(n):
    assert n > 1

when run with pytest --replay-record-dir ., generates a file containing

{"nodeid": "tests/test_foo.py::test_name[1]", "start": 0.03358029099990745}
{"nodeid": "tests/test_foo.py::test_name[1]", "start": 0.03358029099990745, "finish": 0.03893194400006905, "outcome": "passed"}
{"nodeid": "tests/test_foo.py::test_name[2]", "start": 0.039133442000093055}
{"nodeid": "tests/test_foo.py::test_name[2]", "start": 0.039133442000093055, "finish": 0.039566410000134056, "outcome": "passed"}
{"nodeid": "tests/test_foo.py::test_name[3]", "start": 0.039726459000121395}
{"nodeid": "tests/test_foo.py::test_name[3]", "start": 0.039726459000121395, "finish": 0.04012836599986258, "outcome": "passed"}

while the test output is:

$ pytest --replay-record-dir .
# other stuff
FAILED tests/test_foo.py::test_name[1] - assert 1 > 1
============================================ 1 failed, 2 passed in 0.06s =============================================

The problem seems to be in the pytest_runtest_makereport hook, that logs the outcome of the "teardown" phase, that is success, while the test outcome is in the "call" phase.

I'm opening a PR for this soon.

DavideCanton pushed a commit to DavideCanton/pytest-replay that referenced this issue Aug 24, 2024
DavideCanton added a commit to DavideCanton/pytest-replay that referenced this issue Aug 24, 2024
DavideCanton added a commit to DavideCanton/pytest-replay that referenced this issue Aug 27, 2024
prusse-martin added a commit that referenced this issue Aug 28, 2024
Report correct outcome in the replay file (#64)
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

Successfully merging a pull request may close this issue.

1 participant