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

Feature/attach log stdout stderr #285

Merged

Conversation

Sup3rGeo
Copy link
Contributor

@Sup3rGeo Sup3rGeo commented Aug 19, 2018

EDIT: Not WIP anymore, tests added.

Adds automatically captured logs, stdout and stderr as attachments to the test body.

Also fixes a small bug for cases where there is no package.

//: # (
. Thank you so much for sending us a pull request!
.
. Make sure you have a clear name for your pull request.
. The name should start with a capital letter and no dot is required in the end of the sentence.
. To link the request with isses use the following notation: (fixes #123, fixes #321)
.
. An example of good pull request names:
. - Add Russian translation (fixes #123)
. - Add an ability to disable default plugins
. - Support emoji in test descriptions
)

Context

Checklist

@Sup3rGeo
Copy link
Contributor Author

Sup3rGeo commented Aug 20, 2018

Also this test will fail because of a pytest bug whose fix PR is still to be merged and released:

pytest-dev/pytest#3819

(@sseliverstov so the only test that is failing is the one for this feature itself. Could you at least review the implementation/test and then we can wait to merge when the new pytest release comes and this test passes?)

@sseliverstov
Copy link
Contributor

@Sup3rGeo test uses yield fixture, can you rebase please?

…ython into feature/attach-log-stdout-stderr

# Conflicts:
#	allure-pytest/src/utils.py
@Sup3rGeo
Copy link
Contributor Author

Sup3rGeo commented Aug 22, 2018

Rebased. The tests will probably fail until pytest-3.7.3 is out (the bug fix PR was already merged to master).

@sseliverstov do you think it is a good idea to make this feature active by default? I am wondering if we would typically always want to add this info to the allure report (and prevent having to add the option in every test run), and would not only in a few exception cases.

@sseliverstov
Copy link
Contributor

@Sup3rGeo,
Does it work with older pytest? If it loses some strings it is ok, just no faults wanted.
In old allure (v1.xx) it enabled by default. On other hand, we have pytest options:
--capture=method per-test capturing method: one of fd|sys|no.
-s shortcut for --capture=no.
Does it works correctly with all options?
What about behave, depended to pytest options?

@Sup3rGeo
Copy link
Contributor Author

I think it makes sense to make it dependent on pytest capture options - that way there is an equivalence between the output in allure and in console.

Currently, if capture is disabled, an empty file is attached. But we can just disable everything if pytest capture is disabled.

By default capture is fd, but I can try with sys as well. Is there an easy way of parametrizing the doctests?

I also tried writing some plain tests (using pytester plugin - the one pytest uses to test itself) but they don't seem to work without something inside docstrings. Is this normal?

@Sup3rGeo
Copy link
Contributor Author

@sseliverstov pushed another commit:

  • Tested with all pytest capture options, also disabling pytest logging
  • When they are disabled, we still attach a file, but empty
  • This option now is enabled by default

There seems to be, however, something seriously broken with the tests the way they are with doctest. If I put them all in the same module, they get really flaky, failing randomly. I had to put them in separate modules to have the tests running fine.

I think we should think about getting rid of doctests, as everything it does could be done with the pytester plugin and also doctests lack parametrization, cannot be run with regular non doctest tests, etc...

@sseliverstov sseliverstov merged commit f4e592e into allure-framework:master Sep 28, 2018
@Sup3rGeo Sup3rGeo deleted the feature/attach-log-stdout-stderr branch September 29, 2018 23:36
@FerrisYu
Copy link

FerrisYu commented May 7, 2019

Is it possible to disable the console log output empty file behavior? All of my tests are GUI based tests right now, and they just have three empty files now.

@Sup3rGeo
Copy link
Contributor Author

Sup3rGeo commented May 7, 2019

@FerrisYu the --allure-no-capture option should avoid attaching the text files to the report.

@sseliverstov
Copy link
Contributor

@FerrisYu @Sup3rGeo It was fixed on master. From next release empty logs won't be attached to report.

@Sup3rGeo
Copy link
Contributor Author

Sup3rGeo commented May 8, 2019

@sseliverstov thanks, good to know!

@FerrisYu
Copy link

FerrisYu commented May 8, 2019

@sseliverstov @Sup3rGeo Thx for the tips!

skhomuti pushed a commit to skhomuti/allure-python that referenced this pull request Nov 18, 2020
beckerGil pushed a commit to beckerGil/allure-python that referenced this pull request Apr 10, 2023
IvanBuruyane pushed a commit to IvanBuruyane/allure-python that referenced this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants