Skip to content

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

Closed
@goodspark

Description

@goodspark

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'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: reportingrelated to terminal output and user-facing messages and errorstype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions