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

fix logreport #10496

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3af3f56
Prepare release version 7.2.0
pytestbot Oct 23, 2022
ac4e3cc
Merge pull request #10412 from pytest-dev/release-7.2.0
RonnyPfannschmidt Oct 25, 2022
5c6a9a6
[7.2.x] upgrade pygments-pytest for 7.2.x coloring
asottile Oct 25, 2022
1f08cd7
[7.2.x] Add the PyPI classifier for Python 3.11
bryant1410 Oct 25, 2022
651c7bf
[7.2.x] Edit changelog for 7.2.0 (#10429)
github-actions[bot] Oct 25, 2022
6a4a0f4
Merge pull request #10430 from pytest-dev/backport-10425-to-7.2.x
nicoddemus Oct 25, 2022
8606feb
Merge pull request #10431 from pytest-dev/backport-10426-to-7.2.x
nicoddemus Oct 25, 2022
23bbd5a
Merge pull request #10417 from nicoddemus/publish-action-pin
nicoddemus Oct 25, 2022
eff2e2d
Merge pull request #10432 from nicoddemus/backport-10417
nicoddemus Oct 25, 2022
6a5076d
[7.2.x] Fix 'importlib.abc.TraversableResources' deprecation warning …
github-actions[bot] Oct 31, 2022
b2271af
[7.2.x] Remove done trainings (#10472)
github-actions[bot] Nov 4, 2022
dbd4c5f
[7.2.x] Fix test_raising_repr test
nicoddemus Nov 9, 2022
47d6adf
Merge pull request #10489 from pytest-dev/backport-10488-to-7.2.x
nicoddemus Nov 9, 2022
512fc73
fix logreport
anb76ru Nov 12, 2022
bcd6c8e
fix method pytest_runtest_logreport
anb76ru Nov 15, 2022
5bee912
fix double stdout
anb76ru Nov 15, 2022
45b7df3
Revert "fix double stdout"
anb76ru Nov 15, 2022
30e39f5
fix double_stdout 2
anb76ru Nov 15, 2022
3587419
fix
anb76ru Nov 28, 2022
534feec
fix logreport
anb76ru Nov 12, 2022
c178ff5
fix method pytest_runtest_logreport
anb76ru Nov 15, 2022
0caf7db
fix double stdout
anb76ru Nov 15, 2022
9c91c96
Revert "fix double stdout"
anb76ru Nov 15, 2022
e33fd03
fix double_stdout 2
anb76ru Nov 15, 2022
c17297d
fix
anb76ru Nov 28, 2022
a6e258a
Merge branch '7.2.0/anb76ru/fix_logreport' of https://github.com/anb7…
anb76ru Nov 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/en/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ Bug Fixes
- `#9877 <https://github.com/pytest-dev/pytest/issues/9877>`_: Ensure ``caplog.get_records(when)`` returns current/correct data after invoking ``caplog.clear()``.


- `#10491 <https://github.com/pytest-dev/pytest/issues/10491>`_: Method ``pytest_runtest_logreport`` generated report in case test passed or test failed and ``when=='call'``.


Improved Documentation
----------------------
Expand Down
3 changes: 1 addition & 2 deletions src/_pytest/junitxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,7 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
if report.when == "call":
reporter.append_failure(report)
self.open_reports.append(report)
if not self.log_passing_tests:
reporter.write_captured_output(report)
reporter.write_captured_output(report)
else:
reporter.append_error(report)
elif report.skipped:
Expand Down
31 changes: 31 additions & 0 deletions testing/test_junitxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,37 @@ def test_function(arg):
assert "hello-stdout call" in systemout.toxml()
assert "hello-stdout teardown" in systemout.toxml()

@pytest.mark.parametrize("junit_logging", ["no", "system-out"])
def test_call_failed_stdout(
self, pytester: Pytester, run_and_parse: RunAndParse, junit_logging: str
) -> None:
pytester.makepyfile(
"""
import sys
import pytest

@pytest.fixture
def arg(request):
yield
sys.stdout.write('hello-stdout teardown')
raise ValueError()
def test_function(arg):
sys.stdout.write('hello-stdout call')
raise ValueError()
"""
)
result, dom = run_and_parse("-o", "junit_logging=%s" % junit_logging)
node = dom.find_first_by_tag("testsuite")
pnode = node.find_first_by_tag("testcase")
if junit_logging == "no":
assert not node.find_by_tag(
"system-out"
), "system-out should not be generated"
if junit_logging == "system-out":
systemout = pnode.find_first_by_tag("system-out")
assert systemout
assert "hello-stdout call" in systemout.toxml()


def test_mangle_test_address() -> None:
from _pytest.junitxml import mangle_test_address
Expand Down