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

"--show-capture=no" option still capture teardown logs. #3816

Closed
eskignax opened this Issue Aug 15, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@eskignax

eskignax commented Aug 15, 2018

Hello, I wanted to use --show-capture=no option to hide the captured log.

Environment:

  • platform linux -- Python 3.6.5, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
  • Running with PyCharm
  • plugins: allure-pytest-2.3.2b1

Without the option the console display:

  • Captured log setup
  • Captured log call
  • Captured log teardown

Using the option the current result is:

  • Captured log setup
  • Captured log call
  • Captured log teardown

The expected result is to not show any captured log at all.

  • Captured log setup
  • Captured log call
  • Captured log teardown

Here some code to reproduce it:

import pytest
import logging


@pytest.fixture(scope="function", autouse="True")
def hook_each_test_(request):
    logging.error("BEFORE (SETUP)")
    yield
    logging.error("AFTER (tearddown)")


def test_allure_error():
    logging.error("IN TEST")
    assert True == False

Result without the option:

=================================== FAILURES ===================================
______________________________ test_allure_error _______________________________

    def test_allure_error():
        logging.error("IN TEST")
>       assert True == False
E       assert True == False

test_slash.py:14: AssertionError
------------------------------ Captured log setup ------------------------------
test_slash.py                7 ERROR    BEFORE (SETUP)
------------------------------ Captured log call -------------------------------
test_slash.py               13 ERROR    IN TEST
---------------------------- Captured log teardown -----------------------------
test_slash.py                9 ERROR    AFTER (tearddown)
=========================== 1 failed in 0.02 seconds ===========================

Result with the option:

=================================== FAILURES ===================================
______________________________ test_allure_error _______________________________

    def test_allure_error():
        logging.error("IN TEST")
>       assert True == False
E       assert True == False

test_slash.py:14: AssertionError
---------------------------- Captured log teardown -----------------------------
test_slash.py                9 ERROR    AFTER (tearddown)
=========================== 1 failed in 0.02 seconds ===========================

Process finished with exit code 0

sankt-petersbug added a commit to sankt-petersbug/pytest that referenced this issue Aug 20, 2018

Fix '--show-capture=no' capture teardown logs
Add a check before printing teardown logs.

'print_teardown_sections' method does not check '--show-capture' option
value, and teardown logs are always printed.

Resolves: #3816

cmccandless added a commit to cmccandless/multisite that referenced this issue Aug 30, 2018

Update pytest to 3.7.4 (#10)
This PR updates [pytest](https://pypi.org/project/pytest) from **3.7.2** to **3.7.4**.



<details>
  <summary>Changelog</summary>
  
  
   ### 3.7.4
   ```
   =========================

Bug Fixes
---------

- `3506 &lt;https://github.com/pytest-dev/pytest/issues/3506&gt;`_: Fix possible infinite recursion when writing ``.pyc`` files.


- `3853 &lt;https://github.com/pytest-dev/pytest/issues/3853&gt;`_: Cache plugin now obeys the ``-q`` flag when ``--last-failed`` and ``--failed-first`` flags are used.


- `3883 &lt;https://github.com/pytest-dev/pytest/issues/3883&gt;`_: Fix bad console output when using ``console_output_style=classic``.


- `3888 &lt;https://github.com/pytest-dev/pytest/issues/3888&gt;`_: Fix macOS specific code using ``capturemanager`` plugin in doctests.



Improved Documentation
----------------------

- `3902 &lt;https://github.com/pytest-dev/pytest/issues/3902&gt;`_: Fix pytest.org links
   ```
   
  
  
   ### 3.7.3
   ```
   =========================

Bug Fixes
---------

- `3033 &lt;https://github.com/pytest-dev/pytest/issues/3033&gt;`_: Fixtures during teardown can again use ``capsys`` and ``capfd`` to inspect output captured during tests.


- `3773 &lt;https://github.com/pytest-dev/pytest/issues/3773&gt;`_: Fix collection of tests from ``__init__.py`` files if they match the ``python_files`` configuration option.


- `3796 &lt;https://github.com/pytest-dev/pytest/issues/3796&gt;`_: Fix issue where teardown of fixtures of consecutive sub-packages were executed once, at the end of the outer
  package.


- `3816 &lt;https://github.com/pytest-dev/pytest/issues/3816&gt;`_: Fix bug where ``--show-capture=no`` option would still show logs printed during fixture teardown.


- `3819 &lt;https://github.com/pytest-dev/pytest/issues/3819&gt;`_: Fix ``stdout/stderr`` not getting captured when real-time cli logging is active.


- `3843 &lt;https://github.com/pytest-dev/pytest/issues/3843&gt;`_: Fix collection error when specifying test functions directly in the command line using ``test.py::test`` syntax together with ``--doctest-modules``.


- `3848 &lt;https://github.com/pytest-dev/pytest/issues/3848&gt;`_: Fix bugs where unicode arguments could not be passed to ``testdir.runpytest`` on Python 2.


- `3854 &lt;https://github.com/pytest-dev/pytest/issues/3854&gt;`_: Fix double collection of tests within packages when the filename starts with a capital letter.



Improved Documentation
----------------------

- `3824 &lt;https://github.com/pytest-dev/pytest/issues/3824&gt;`_: Added example for multiple glob pattern matches in ``python_files``.


- `3833 &lt;https://github.com/pytest-dev/pytest/issues/3833&gt;`_: Added missing docs for ``pytester.Testdir``.


- `3870 &lt;https://github.com/pytest-dev/pytest/issues/3870&gt;`_: Correct documentation for setuptools integration.



Trivial/Internal Changes
------------------------

- `3826 &lt;https://github.com/pytest-dev/pytest/issues/3826&gt;`_: Replace broken type annotations with type comments.


- `3845 &lt;https://github.com/pytest-dev/pytest/issues/3845&gt;`_: Remove a reference to issue `568 &lt;https://github.com/pytest-dev/pytest/issues/568&gt;`_ from the documentation, which has since been
  fixed.
   ```
   
  
</details>


 

<details>
  <summary>Links</summary>
  
  - PyPI: https://pypi.org/project/pytest
  - Changelog: https://pyup.io/changelogs/pytest/
  - Homepage: https://docs.pytest.org/en/latest/
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment