Skip to content

Add option/config to collapse file/module/line data for warnings #6591

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

Closed
goodspark opened this issue Jan 28, 2020 · 2 comments · Fixed by #6834
Closed

Add option/config to collapse file/module/line data for warnings #6591

goodspark opened this issue Jan 28, 2020 · 2 comments · Fixed by #6834
Labels
topic: reporting related to terminal output and user-facing messages and errors type: enhancement new feature or API change, should be merged into features branch

Comments

@goodspark
Copy link

goodspark commented Jan 28, 2020

Python 3.8.1
pytest 5.3.4
Ubuntu 18.04

pip list
Package        Version
-------------- -------
attrs          19.3.0 
more-itertools 8.1.0  
packaging      20.1   
pip            20.0.2 
pluggy         0.13.1 
py             1.8.1  
pyparsing      2.4.6  
pytest         5.3.4  
setuptools     45.1.0 
six            1.14.0 
wcwidth        0.1.8  
wheel          0.34.1 

test_it.py

import pytest
import warnings

@pytest.mark.parametrize("a", sorted(range(3)))
def test_1(a):
    warnings.warn("deprecated", DeprecationWarning)
pytest .
===================== test session starts ======================
platform linux -- Python 3.8.1, pytest-5.3.4, py-1.8.1, pluggy-0.13.1
rootdir: /home/sam/tmp/py38, inifile: setup.cfg
collected 3 items                                              

test_it.py ...                                           [100%]

======================= warnings summary =======================
test_it.py::test_1[0]
test_it.py::test_1[1]
test_it.py::test_1[2]
  /home/sam/tmp/py38/test_it.py:6: DeprecationWarning: deprecated
    warnings.warn("deprecated", DeprecationWarning)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
================ 3 passed, 3 warnings in 0.01s =================

I'd like a way to hide/collapse/combine all the file/module/line data that gets printed out in the warnings summary. For larger projects with spaghetti code, it's quite possible this print out ends up being hundreds of lines long.

The same happens when I try to use the "once" action for filter warnings. Which kind of makes sense. That warning is still only being shown 'once'.

@blueyed blueyed added topic: reporting related to terminal output and user-facing messages and errors type: enhancement new feature or API change, should be merged into features branch labels Jan 28, 2020
@blueyed
Copy link
Contributor

blueyed commented Jan 28, 2020

Makes sense.
Note that there is some collapsing being done for "SKIPPED", but it could be improved in general also (e.g. with regard to providing an option to collapse / collapsing similar skips via/from different source lines).
So this should likely be looked at / refactored when doing it for warnings then.

@nicoddemus
Copy link
Member

Perhaps makes sense to collapse automatically with the default verbosity, and keep the existing display with -v or greater?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants