-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
plugin: warningsrelated to the warnings builtin pluginrelated to the warnings builtin plugintype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch
Milestone
Description
The warnings docs clearly state that it captures warnings during test execution, but that means any warnings issued during test collection will not be captured and will silently pass. Consider this slight tweak to the canonical example:
$ cat test_show_warnings.py
import warnings
warnings.warn("foo", UserWarning)
def test_one():
assert True
$ .tox/python/bin/pytest test_show_warnings.py -s
====================================== test session starts =======================================
platform darwin -- Python 3.7.0b1, pytest-3.4.1, py-1.5.2, pluggy-0.6.0
rootdir: /Users/jaraco/warnings, inifile:
collecting 0 items /Users/jaraco/warnings/test_show_warnings.py:4: UserWarning: foo
warnings.warn("foo", UserWarning)
collected 1 item
test_show_warnings.py .
==================================== 1 passed in 0.00 seconds ====================================
$ .tox/python/bin/pytest test_show_warnings.py
====================================== test session starts =======================================
platform darwin -- Python 3.7.0b1, pytest-3.4.1, py-1.5.2, pluggy-0.6.0
rootdir: /Users/jaraco/warnings, inifile:
collected 1 item
test_show_warnings.py . [100%]
==================================== 1 passed in 0.00 seconds ====================================
Would it be possible for the warnings feature to also be enabled during test collection, such that warnings like these could also be captured and reported and tweaked by the pytest config?
edmorley, unnonouno and arbabali
Metadata
Metadata
Assignees
Labels
plugin: warningsrelated to the warnings builtin pluginrelated to the warnings builtin plugintype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch