getsentry / responses

A utility for mocking out the Python Requests library.
Apache License 2.0
4.08k stars 347 forks source link

0.25.0: pytest fails in two units #706

Closed kloczek closed 4 weeks ago

kloczek commented 4 months ago

Describe the bug

Despite fact that in build env is installed pytest-asyncio pytest fails in two units complaining about missing suitable plugin for async framework.

Additional context

List of installed modules in build env: ```console Package Version ------------------ -------- build 1.0.3 charset-normalizer 3.3.2 cppclean 0.13 distro 1.9.0 dnf 4.19.0 exceptiongroup 1.1.3 gpg 1.23.2 idna 3.6 importlib_metadata 7.0.1 iniconfig 2.0.0 installer 0.7.0 libdnf 0.73.0 MarkupSafe 2.1.3 mock 5.1.0 packaging 23.2 pluggy 1.3.0 pyproject_hooks 1.0.0 pytest 8.0.0 pytest-asyncio 0.23.5 pytest_httpserver 1.0.9 python-dateutil 2.8.2 PyYAML 6.0.1 requests 2.31.0 setuptools 69.1.0 six 1.16.0 testpath 0.6.0 toml 0.10.2 tomli 2.0.1 tomli_w 1.0.0 urllib3 1.26.18 Werkzeug 3.0.1 wheel 0.42.0 zipp 3.17.0 ```

Version of responses

0.25.0

Steps to Reproduce

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Expected Result

pytest should not fail.

Actual Result

Here is pytest output: ```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-responses-0.25.0-4.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-responses-0.25.0-4.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -m 'not network' ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.8.18, pytest-8.0.0, pluggy-1.3.0 rootdir: /home/tkloczko/rpmbuild/BUILD/responses-0.25.0 configfile: tox.ini plugins: asyncio-0.23.5, pytest_httpserver-1.0.9 asyncio: mode=strict collected 212 items responses/tests/test_matchers.py .................................. [ 16%] responses/tests/test_multithreading.py .......... [ 20%] responses/tests/test_recorder.py .... [ 22%] responses/tests/test_registries.py ...F..... [ 26%] responses/tests/test_responses.py ..................................................................................................................................F................ [ 96%] ........ [100%] ========================================================================================= FAILURES ========================================================================================== ____________________________________________________________________________________ test_registry_async ____________________________________________________________________________________ cls = , func = . at 0x7f6587294c10>, when = 'call' reraise = (, ) @classmethod def from_call( cls, func: Callable[[], TResult], when: Literal["collect", "setup", "call", "teardown"], reraise: Optional[ Union[Type[BaseException], Tuple[Type[BaseException], ...]] ] = None, ) -> "CallInfo[TResult]": """Call func, wrapping the result in a CallInfo. :param func: The function to call. Called without arguments. :param when: The phase in which the function is called. :param reraise: Exception or exceptions that shall propagate if raised by the function, instead of being wrapped in the CallInfo. """ excinfo = None start = timing.time() precise_start = timing.perf_counter() try: > result: Optional[TResult] = func() /usr/lib/python3.8/site-packages/_pytest/runner.py:345: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.8/site-packages/_pytest/runner.py:266: in lambda: ihook(item=item, **kwds), when=when, reraise=reraise /usr/lib/python3.8/site-packages/pluggy/_hooks.py:493: in __call__ return self._hookexec(self.name, self._hookimpls, kwargs, firstresult) /usr/lib/python3.8/site-packages/pluggy/_manager.py:115: in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) /usr/lib/python3.8/site-packages/_pytest/threadexception.py:87: in pytest_runtest_call yield from thread_exception_runtest_hook() /usr/lib/python3.8/site-packages/_pytest/threadexception.py:63: in thread_exception_runtest_hook yield /usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:90: in pytest_runtest_call yield from unraisable_exception_runtest_hook() /usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:65: in unraisable_exception_runtest_hook yield /usr/lib/python3.8/site-packages/_pytest/logging.py:839: in pytest_runtest_call yield from self._runtest_for(item, "call") /usr/lib/python3.8/site-packages/_pytest/logging.py:822: in _runtest_for yield /usr/lib/python3.8/site-packages/_pytest/capture.py:882: in pytest_runtest_call return (yield) /usr/lib/python3.8/site-packages/_pytest/skipping.py:257: in pytest_runtest_call return (yield) /usr/lib/python3.8/site-packages/_pytest/runner.py:181: in pytest_runtest_call raise e /usr/lib/python3.8/site-packages/_pytest/runner.py:173: in pytest_runtest_call item.runtest() /usr/lib/python3.8/site-packages/_pytest/python.py:1841: in runtest self.ihook.pytest_pyfunc_call(pyfuncitem=self) /usr/lib/python3.8/site-packages/pluggy/_hooks.py:493: in __call__ return self._hookexec(self.name, self._hookimpls, kwargs, firstresult) /usr/lib/python3.8/site-packages/pluggy/_manager.py:115: in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) /usr/lib/python3.8/site-packages/_pytest/python.py:195: in pytest_pyfunc_call async_warn_and_skip(pyfuncitem.nodeid) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ nodeid = 'responses/tests/test_registries.py::test_registry_async' def async_warn_and_skip(nodeid: str) -> None: msg = "async def functions are not natively supported and have been skipped.\n" msg += ( "You need to install a suitable plugin for your async framework, for example:\n" ) msg += " - anyio\n" msg += " - pytest-asyncio\n" msg += " - pytest-tornasync\n" msg += " - pytest-trio\n" msg += " - pytest-twisted" > warnings.warn(PytestUnhandledCoroutineWarning(msg.format(nodeid))) E pytest.PytestUnhandledCoroutineWarning: async def functions are not natively supported and have been skipped. E You need to install a suitable plugin for your async framework, for example: E - anyio E - pytest-asyncio E - pytest-tornasync E - pytest-trio E - pytest-twisted /usr/lib/python3.8/site-packages/_pytest/python.py:187: PytestUnhandledCoroutineWarning _____________________________________________________________________________________ test_async_calls ______________________________________________________________________________________ cls = , func = . at 0x7f6587ad1040>, when = 'call' reraise = (, ) @classmethod def from_call( cls, func: Callable[[], TResult], when: Literal["collect", "setup", "call", "teardown"], reraise: Optional[ Union[Type[BaseException], Tuple[Type[BaseException], ...]] ] = None, ) -> "CallInfo[TResult]": """Call func, wrapping the result in a CallInfo. :param func: The function to call. Called without arguments. :param when: The phase in which the function is called. :param reraise: Exception or exceptions that shall propagate if raised by the function, instead of being wrapped in the CallInfo. """ excinfo = None start = timing.time() precise_start = timing.perf_counter() try: > result: Optional[TResult] = func() /usr/lib/python3.8/site-packages/_pytest/runner.py:345: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.8/site-packages/_pytest/runner.py:266: in lambda: ihook(item=item, **kwds), when=when, reraise=reraise /usr/lib/python3.8/site-packages/pluggy/_hooks.py:493: in __call__ return self._hookexec(self.name, self._hookimpls, kwargs, firstresult) /usr/lib/python3.8/site-packages/pluggy/_manager.py:115: in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) /usr/lib/python3.8/site-packages/_pytest/threadexception.py:87: in pytest_runtest_call yield from thread_exception_runtest_hook() /usr/lib/python3.8/site-packages/_pytest/threadexception.py:63: in thread_exception_runtest_hook yield /usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:90: in pytest_runtest_call yield from unraisable_exception_runtest_hook() /usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:65: in unraisable_exception_runtest_hook yield /usr/lib/python3.8/site-packages/_pytest/logging.py:839: in pytest_runtest_call yield from self._runtest_for(item, "call") /usr/lib/python3.8/site-packages/_pytest/logging.py:822: in _runtest_for yield /usr/lib/python3.8/site-packages/_pytest/capture.py:882: in pytest_runtest_call return (yield) /usr/lib/python3.8/site-packages/_pytest/skipping.py:257: in pytest_runtest_call return (yield) /usr/lib/python3.8/site-packages/_pytest/runner.py:181: in pytest_runtest_call raise e /usr/lib/python3.8/site-packages/_pytest/runner.py:173: in pytest_runtest_call item.runtest() /usr/lib/python3.8/site-packages/_pytest/python.py:1841: in runtest self.ihook.pytest_pyfunc_call(pyfuncitem=self) /usr/lib/python3.8/site-packages/pluggy/_hooks.py:493: in __call__ return self._hookexec(self.name, self._hookimpls, kwargs, firstresult) /usr/lib/python3.8/site-packages/pluggy/_manager.py:115: in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) /usr/lib/python3.8/site-packages/_pytest/python.py:195: in pytest_pyfunc_call async_warn_and_skip(pyfuncitem.nodeid) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ nodeid = 'responses/tests/test_responses.py::test_async_calls' def async_warn_and_skip(nodeid: str) -> None: msg = "async def functions are not natively supported and have been skipped.\n" msg += ( "You need to install a suitable plugin for your async framework, for example:\n" ) msg += " - anyio\n" msg += " - pytest-asyncio\n" msg += " - pytest-tornasync\n" msg += " - pytest-trio\n" msg += " - pytest-twisted" > warnings.warn(PytestUnhandledCoroutineWarning(msg.format(nodeid))) E pytest.PytestUnhandledCoroutineWarning: async def functions are not natively supported and have been skipped. E You need to install a suitable plugin for your async framework, for example: E - anyio E - pytest-asyncio E - pytest-tornasync E - pytest-trio E - pytest-twisted /usr/lib/python3.8/site-packages/_pytest/python.py:187: PytestUnhandledCoroutineWarning ===================================================================================== warnings summary ====================================================================================== responses/tests/test_matchers.py: 2 warnings responses/tests/test_responses.py: 8 warnings /home/tkloczko/rpmbuild/BUILD/responses-0.25.0/responses/__init__.py:436: DeprecationWarning: Argument 'match_querystring' is deprecated. Use 'responses.matchers.query_param_matcher' or 'responses.matchers.query_string_matcher' warn( responses/tests/test_responses.py::test_response_cookies_session[True-True] responses/tests/test_responses.py::test_response_cookies_session[True-False] responses/tests/test_responses.py::test_response_cookies_session[True-None] responses/tests/test_responses.py::test_response_cookies_session[False-True] responses/tests/test_responses.py::test_response_cookies_session[False-False] responses/tests/test_responses.py::test_response_cookies_session[False-None] responses/tests/test_responses.py::test_response_filebody responses/tests/test_responses.py::test_use_stream_twice_to_double_raw_io /home/tkloczko/rpmbuild/BUILD/responses-0.25.0/responses/__init__.py:607: DeprecationWarning: stream argument is deprecated. Use stream parameter in request directly warn( -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ================================================================================== short test summary info ================================================================================== FAILED responses/tests/test_registries.py::test_registry_async - pytest.PytestUnhandledCoroutineWarning: async def functions are not natively supported and have been skipped. FAILED responses/tests/test_responses.py::test_async_calls - pytest.PytestUnhandledCoroutineWarning: async def functions are not natively supported and have been skipped. ======================================================================== 2 failed, 210 passed, 18 warnings in 53.76s ======================================================================== ```

Please let me know if you need more details or want me to perform some diagnostics.

markstory commented 4 months ago

Looks like we're missing some pytest markers. I can get those fixed.

kloczek commented 4 months ago

Do you want me to test https://github.com/getsentry/responses/pull/707? 🤔

markstory commented 4 months ago

Do you want me to test https://github.com/getsentry/responses/pull/707? 🤔

If you want to. My next step would be to do a release for 0.25.1. If that doesn't build again, we'll have a longer feedback loop to getting a build that does work.

kloczek commented 4 months ago
Here is pytest output: ```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-responses-0.25.0-4.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-responses-0.25.0-4.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -m 'not network' ============================= test session starts ============================== platform linux -- Python 3.8.18, pytest-8.0.0, pluggy-1.3.0 rootdir: /home/tkloczko/rpmbuild/BUILD/responses-0.25.0 configfile: tox.ini plugins: asyncio-0.23.5, pytest_httpserver-1.0.9 asyncio: mode=strict collected 212 items responses/tests/test_matchers.py .................................. [ 16%] responses/tests/test_multithreading.py .......... [ 20%] responses/tests/test_recorder.py .... [ 22%] responses/tests/test_registries.py ......... [ 26%] responses/tests/test_responses.py ...................................... [ 44%] ........................................................................ [ 78%] ............................................. [100%] =============================== warnings summary =============================== responses/tests/test_matchers.py: 2 warnings responses/tests/test_responses.py: 8 warnings /home/tkloczko/rpmbuild/BUILD/responses-0.25.0/responses/__init__.py:436: DeprecationWarning: Argument 'match_querystring' is deprecated. Use 'responses.matchers.query_param_matcher' or 'responses.matchers.query_string_matcher' warn( responses/tests/test_responses.py::test_response_cookies_session[True-True] responses/tests/test_responses.py::test_response_cookies_session[True-False] responses/tests/test_responses.py::test_response_cookies_session[True-None] responses/tests/test_responses.py::test_response_cookies_session[False-True] responses/tests/test_responses.py::test_response_cookies_session[False-False] responses/tests/test_responses.py::test_response_cookies_session[False-None] responses/tests/test_responses.py::test_response_filebody responses/tests/test_responses.py::test_use_stream_twice_to_double_raw_io /home/tkloczko/rpmbuild/BUILD/responses-0.25.0/responses/__init__.py:607: DeprecationWarning: stream argument is deprecated. Use stream parameter in request directly warn( -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ====================== 212 passed, 18 warnings in 55.36s ======================= ```
markstory commented 4 months ago

Thank you @kloczek That looks much better. I'll get a release tagged.

kloczek commented 1 month ago

0Just test ed 0.25.2 and all looks good. I see only one pytest warning.

===================================================================================== warnings summary ======================================================================================
responses/tests/test_matchers.py: 2 warnings
responses/tests/test_responses.py: 8 warnings
  /home/tkloczko/rpmbuild/BUILD/responses-0.25.2/responses/__init__.py:436: DeprecationWarning: Argument 'match_querystring' is deprecated. Use 'responses.matchers.query_param_matcher' or 'responses.matchers.query_string_matcher'
    warn(

responses/tests/test_responses.py::test_response_cookies_session[True-True]
responses/tests/test_responses.py::test_response_cookies_session[True-False]
responses/tests/test_responses.py::test_response_cookies_session[True-None]
responses/tests/test_responses.py::test_response_cookies_session[False-True]
responses/tests/test_responses.py::test_response_cookies_session[False-False]
responses/tests/test_responses.py::test_response_cookies_session[False-None]
responses/tests/test_responses.py::test_response_filebody
responses/tests/test_responses.py::test_use_stream_twice_to_double_raw_io
  /home/tkloczko/rpmbuild/BUILD/responses-0.25.2/responses/__init__.py:609: DeprecationWarning: stream argument is deprecated. Use stream parameter in request directly
    warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================= 215 passed, 18 warnings in 41.65s =============================================================================