Repository: aio-libs/aiohttp

Issue:
aiohttp.pytest_plugin suppresses all the warnings
🐞 **Describe the bug**
<!-- A clear and concise description of what the bug is, on the next line. -->

`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**
<!-- How to reproduce the behavior?

For example:
1. Have certain environment
2. Run given code snippet in a certain way
3. See some behavior described

Add these steps below this comment: -->

Simple testcase that shows how pytest works with warnings. It would print warning for test_foo only.

```python
import warnings

def test_foo():
    warnings.warn('sync warning')


async def test_afoo():
    warnings.warn('async warning')
```


💡 **Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->

pytest catches warning.

📋 **Logs/tracebacks**
<!-- If applicable, add logs/tracebacks to help explain your problem. -->
```python-traceback (paste your traceback in the next line)
========================= 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**
<!-- Attach your version of the Python. -->
```console
$ python --version
Python 3.7.3
```

📋 **Your version of the aiohttp/yarl/multidict distributions**
<!-- Attach your version of the distributions in the code blocks below. -->
```console
$ 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
```
```console
$ 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
```
```console
$ 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**
<!-- Add any other context about the problem here, in the next line. -->

<!-- Describe the environment you have that lead to your issue.
     This includes aiohttp version, OS, proxy server and other bits that
     are related to your case.

     IMPORTANT: aiohttp is both server framework and client library.
     For getting rid of confusing please put 'server', 'client' or 'both'
     word here.
     -->



Discussion:
Feel free to send a PR.

Resolving patch:
diff --git a/aiohttp/pytest_plugin.py b/aiohttp/pytest_plugin.py
--- a/aiohttp/pytest_plugin.py
+++ b/aiohttp/pytest_plugin.py
@@ -129,6 +129,13 @@ def _runtime_warning_context():  # type: ignore
                 '\n'.join(rw)
             ))
 
+    # Propagate warnings to pytest
+    for msg in _warnings:
+        warnings.showwarning(
+            msg.message,   # type: ignore
+            msg.category, msg.filename, msg.lineno, msg.file, msg.line
+        )
+
 
 @contextlib.contextmanager
 def _passthrough_loop_context(loop, fast=False):  # type: ignore


Test patch:
diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py
--- a/tests/test_pytest_plugin.py
+++ b/tests/test_pytest_plugin.py
@@ -1,9 +1,12 @@
 import os
 import platform
 import sys
+import warnings
 
 import pytest
 
+from aiohttp import pytest_plugin
+
 pytest_plugins = 'pytester'
 
 CONFTEST = '''
@@ -243,3 +246,12 @@ def test_finalized() -> None:
     testdir.makeconftest(CONFTEST)
     result = testdir.runpytest('-p', 'no:sugar', '--aiohttp-loop=pyloop')
     result.assert_outcomes(passed=2)
+
+
+def test_warnings_propagated(recwarn):
+    with pytest_plugin._runtime_warning_context():
+        warnings.warn('test warning is propagated')
+    assert len(recwarn) == 1
+    message = recwarn[0].message
+    assert isinstance(message, UserWarning)
+    assert message.args == ('test warning is propagated',)