Skip to content

aiohttp.pytest_plugin suppresses all the warnings #4656

Closed
@vitek

Description

🐞 Describe the bug

aiohttp.pytest_plugin suppresses warnings issued from test. It looks like _runtime_warning_context() catches all the warnings so no warning reaches pytest.warnings plugin.

💡 To Reproduce

Simple testcase that shows how pytest works with warnings. It would print warning for test_foo only.

import warnings

def test_foo():
    warnings.warn('sync warning')


async def test_afoo():
    warnings.warn('async warning')

💡 Expected behavior

pytest catches warning.

📋 Logs/tracebacks

========================= test session starts ==========================
platform linux -- Python 3.7.3, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 -- python3.7
cachedir: .pytest_cache
rootdir: ..., inifile: pytest.ini
plugins: aiohttp-0.3.0
collected 2 items                                                      

tests/test_foo.py::test_foo PASSED
tests/test_foo.py::test_afoo 
PASSED

=========================== warnings summary ===========================
tests/test_foo.py::test_foo
  test_foo.py:4: UserWarning: sync warning
    warnings.warn('sync warning')

-- Docs: https://docs.pytest.org/en/latest/warnings.html
===================== 2 passed, 1 warning in 0.02s =====================

📋 Your version of the Python

$ python --version
Python 3.7.3

📋 Your version of the aiohttp/yarl/multidict distributions

$ python -m pip show aiohttp
Name: aiohttp
Version: 3.6.2
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: Nikolay Kim
Author-email: fafhrd91@gmail.com
License: Apache 2
Location: /home/vitja/work/testsuite/.venv-docs/lib/python3.7/site-packages
Requires: yarl, multidict, chardet, attrs, async-timeout
Required-by: testsuite, pytest-aiohttp
$ python -m pip show multidict
Name: multidict
Version: 4.7.5
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: /home/vitja/work/testsuite/.venv-docs/lib/python3.7/site-packages
Requires: 
Required-by: yarl, aiohttp
$ python -m pip show yarl
Name: yarl
Version: 1.4.2
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: /home/vitja/work/testsuite/.venv-docs/lib/python3.7/site-packages
Requires: idna, multidict
Required-by: aiohttp

📋 Additional context

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions