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

Unable to modify xml reports #2381

Closed
FuriousDuck opened this issue Apr 26, 2017 · 7 comments
Closed

Unable to modify xml reports #2381

FuriousDuck opened this issue Apr 26, 2017 · 7 comments
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity

Comments

@FuriousDuck
Copy link

FuriousDuck commented Apr 26, 2017

It seems that this commit has broken an ability to modify stderr(out) via reporting hooks in xml reports which was pretty useful (because xml reports do not attach custom sections and record_xml_property doesn't work with pytest-xdist)

This code

@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()
    if report.when == 'call':
        if report.skipped and 'xfail' in report.keywords or report.failed and 'xfail' not in report.keywords:
            try:
                fail_info = 'Fail detailed info:\n' + get_fail_info(item)
            except WebDriverException:
                fail_info = 'Fail detailed info:\n\nCaught a webdriver exception. Test session must have failed'
            report.sections.append(('Captured stdout call', fail_info))

is adding some strings to 'Captured stdout call' section of report. After this commit, strings are still visible in console log, but not in xml

@RonnyPfannschmidt
Copy link
Member

@KKoukiou can you take a look at this?

@KKoukiou
Copy link
Contributor

@FuriousDuck @RonnyPfannschmidt I took a look at this issue.
Please replace report.sections.append(('Captured stdout call', fail_info)) in your code
with: item.add_report_section(report.when, "stdout", fail_info) and tell me how it works.
It worked for me fine.

Thanks,
Katerina

@nicoddemus nicoddemus added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label May 15, 2017
@nicoddemus
Copy link
Member

Thanks for looking into it @KKoukiou.

@nicoddemus
Copy link
Member

@FuriousDuck any feedback?

@timyhou
Copy link

timyhou commented Jun 27, 2017

Glad I came across this. I was following this StackOverflow post as a guide. I also experienced the same issue with trying to append to Captured stdout and Captured stderr like the OP described.

However, @KKoukiou suggestion worked for me for stdout or stderr. This is a gem. I couldn't find any documentation describing the right way to modify report sections.

@nicoddemus
Copy link
Member

Added docs in #2567

@FuriousDuck
Copy link
Author

So sorry, missed my part. Like people said, @KKoukiou suggestion works great. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
Projects
None yet
Development

No branches or pull requests

5 participants