Hide captured output
Project description
# pytest-hidecaptured
I write tests that generate a lot of debug messages to console and file.
pytest captures all output from tests and displays them when a test fails.
This behavior is exacerbated when there are a large number of tests within a
test run. Since I already log these messages to file I don't need pytest to
display them on the console. I'd rather it showed me its own reports only.
This issue is exacerbated when others run the same tests. All they care about
is whether the test passed or failed and don't need to see the details. In case
the test failed the debug log files already have the required information.
When any test fails pytest displays all captured output (stdout, stderr, log)
as part of its report. For example,
===== test session starts ======
platform darwin -- Python 3.6.5, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: /home/example/code, inifile:
collected 1 items
test_logging.py F
===== FAILURES =====
----- test_logging -----
def test_logging():
logger.debug('DEBUG!')
logger.info('INFO!')
logger.warning('WARNING!')
logger.error('ERROR!')
logger.critical('CRITICAL!')
> assert False
E assert False
test_logging.py:33: AssertionError
----- Captured stderr call -----
2016-01-19 22:29:40,581 : test_logging : test_logging : test_logging : DEBUG : DEBUG!
2016-01-19 22:29:40,582 : test_logging : test_logging : test_logging : INFO : INFO!
2016-01-19 22:29:40,582 : test_logging : test_logging : test_logging : WARNING : WARNING!
2016-01-19 22:29:40,582 : test_logging : test_logging : test_logging : ERROR : ERROR!
2016-01-19 22:29:40,582 : test_logging : test_logging : test_logging : CRITICAL : CRITICAL!
===== 1 failed in 0.03 seconds =====
pytest-hidecaptured removes the captured output so it is not displayed. For
example, with pytest-hidecaputred installed, the report for the same test is,
===== test session starts ======
platform darwin -- Python 3.6.5, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: /home/example/code, inifile:
plugins: hidecaptured-0.2.2
collected 1 items
test_logging.py F
===== FAILURES =====
----- test_logging -----
def test_logging():
logger.debug('DEBUG!')
logger.info('INFO!')
logger.warning('WARNING!')
logger.error('ERROR!')
logger.critical('CRITICAL!')
> assert False
E assert False
test_logging.py:33: AssertionError
===== 1 failed in 0.02 seconds =====
This [pytest](https://github.com/pytest-dev/pytest) plugin was generated with
[Cookiecutter](https://github.com/audreyr/cookiecutter) along with
[@hackebrot](https://github.com/hackebrot)'s
[Cookiecutter-pytest-plugin](https://github.com/pytest-dev/cookiecutter-pytest-plugin)
template.
# Requirements
* Python
* 2.7 or 3.6+
* pypy2 or pypy3
* pytest 2.8.5+
Note: Older versions of pytest may be compatible but I have not tested them.
# Installation
You can install *pytest-hidecaptured* with ``pip`` from [PyPI](https://pypi.org/),
$ pip install pytest-hidecaptured
# Usage
After installing pytest-hidecaputred use ``pytest`` the way you always have.
There is no additional step required and no additional flag(s) added.
# Contributing
Contributions are very welcome. Tests can be run with ``tox``, please ensure
the coverage at least stays the same before you submit a pull request.
# License
Distributed under the terms of the MIT license, "pytest-hidecaptured" is free
and open source software
# Issues
If you encounter any problems, please
[file an issue](https://github.com/codeghar/pytest-hidecaptured/issues)
along with a detailed description.
# Development
The following targets in *Makefile* help do simple things.
## init
$ make init
Install required packages for development.
## clean
$ make clean
Removes these directories:
- .tox/
- build/
- dist/
## build
$ make build
Build source distribution and universal wheel.
## test
$ make test
Runs ``tox`` to run tests.
## release
$ make release
Upload builds to PyPI. Requires *~/.pypirc* is configured properly.
I write tests that generate a lot of debug messages to console and file.
pytest captures all output from tests and displays them when a test fails.
This behavior is exacerbated when there are a large number of tests within a
test run. Since I already log these messages to file I don't need pytest to
display them on the console. I'd rather it showed me its own reports only.
This issue is exacerbated when others run the same tests. All they care about
is whether the test passed or failed and don't need to see the details. In case
the test failed the debug log files already have the required information.
When any test fails pytest displays all captured output (stdout, stderr, log)
as part of its report. For example,
===== test session starts ======
platform darwin -- Python 3.6.5, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: /home/example/code, inifile:
collected 1 items
test_logging.py F
===== FAILURES =====
----- test_logging -----
def test_logging():
logger.debug('DEBUG!')
logger.info('INFO!')
logger.warning('WARNING!')
logger.error('ERROR!')
logger.critical('CRITICAL!')
> assert False
E assert False
test_logging.py:33: AssertionError
----- Captured stderr call -----
2016-01-19 22:29:40,581 : test_logging : test_logging : test_logging : DEBUG : DEBUG!
2016-01-19 22:29:40,582 : test_logging : test_logging : test_logging : INFO : INFO!
2016-01-19 22:29:40,582 : test_logging : test_logging : test_logging : WARNING : WARNING!
2016-01-19 22:29:40,582 : test_logging : test_logging : test_logging : ERROR : ERROR!
2016-01-19 22:29:40,582 : test_logging : test_logging : test_logging : CRITICAL : CRITICAL!
===== 1 failed in 0.03 seconds =====
pytest-hidecaptured removes the captured output so it is not displayed. For
example, with pytest-hidecaputred installed, the report for the same test is,
===== test session starts ======
platform darwin -- Python 3.6.5, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: /home/example/code, inifile:
plugins: hidecaptured-0.2.2
collected 1 items
test_logging.py F
===== FAILURES =====
----- test_logging -----
def test_logging():
logger.debug('DEBUG!')
logger.info('INFO!')
logger.warning('WARNING!')
logger.error('ERROR!')
logger.critical('CRITICAL!')
> assert False
E assert False
test_logging.py:33: AssertionError
===== 1 failed in 0.02 seconds =====
This [pytest](https://github.com/pytest-dev/pytest) plugin was generated with
[Cookiecutter](https://github.com/audreyr/cookiecutter) along with
[@hackebrot](https://github.com/hackebrot)'s
[Cookiecutter-pytest-plugin](https://github.com/pytest-dev/cookiecutter-pytest-plugin)
template.
# Requirements
* Python
* 2.7 or 3.6+
* pypy2 or pypy3
* pytest 2.8.5+
Note: Older versions of pytest may be compatible but I have not tested them.
# Installation
You can install *pytest-hidecaptured* with ``pip`` from [PyPI](https://pypi.org/),
$ pip install pytest-hidecaptured
# Usage
After installing pytest-hidecaputred use ``pytest`` the way you always have.
There is no additional step required and no additional flag(s) added.
# Contributing
Contributions are very welcome. Tests can be run with ``tox``, please ensure
the coverage at least stays the same before you submit a pull request.
# License
Distributed under the terms of the MIT license, "pytest-hidecaptured" is free
and open source software
# Issues
If you encounter any problems, please
[file an issue](https://github.com/codeghar/pytest-hidecaptured/issues)
along with a detailed description.
# Development
The following targets in *Makefile* help do simple things.
## init
$ make init
Install required packages for development.
## clean
$ make clean
Removes these directories:
- .tox/
- build/
- dist/
## build
$ make build
Build source distribution and universal wheel.
## test
$ make test
Runs ``tox`` to run tests.
## release
$ make release
Upload builds to PyPI. Requires *~/.pypirc* is configured properly.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest-hidecaptured-0.2.2.tar.gz
.
File metadata
- Download URL: pytest-hidecaptured-0.2.2.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b25003ce4196a076596b209c237cb28bcb4eb89e0729c839d958744ea1238013 |
|
MD5 | 328429cab43bd14dbfe028ece25b353d |
|
BLAKE2b-256 | 964769191ecc08bb278c31a8eed064b15d5a17e2e9f94823d1087b6673fe2cff |
File details
Details for the file pytest_hidecaptured-0.2.2-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_hidecaptured-0.2.2-py2.py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb31885974de34adf66212480b0498636ecf5aa5bc5761f7ee7f895f30cdfad2 |
|
MD5 | c989ad6263f9a3a9519837d99b32c6a9 |
|
BLAKE2b-256 | cb66fcb5a824de4f9df48647ecab9ad01965bf4f3639d7ebb9cee193f5c8d734 |