anthropics/anthropic-sdk-python

Test suite fails with pytest 8

Opened this issue · 2 comments

On openSUSE Tumbleweed when we try and run the test suite, we are seeing failures with the following errors.

[   24s] ==================================== ERRORS ====================================
[   24s] ___________ ERROR at setup of TestAsyncMessages.test_basic_response ____________
[   24s] /usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:758: in pytest_fixture_setup
[   24s]     warnings.warn(
[   24s] E   DeprecationWarning: The event_loop fixture provided by pytest-asyncio has been redefined in
[   24s] E   /home/abuild/rpmbuild/BUILD/anthropic-0.33.1/tests/conftest.py:20
[   24s] E   Replacing the event_loop fixture with a custom implementation is deprecated
[   24s] E   and will lead to errors in the future.
[   24s] E   If you want to request an asyncio event loop with a scope other than function
[   24s] E   scope, use the "scope" argument to the asyncio mark when marking the tests.
[   24s] E   If you want to return different types of event loops, use the event_loop_policy
[   24s] E   fixture.
[   24s] 
[   24s] During handling of the above exception, another exception occurred:
[   24s] /usr/lib/python3.10/site-packages/_pytest/runner.py:341: in from_call
[   24s]     result: TResult | None = func()
[   24s] /usr/lib/python3.10/site-packages/_pytest/runner.py:242: in <lambda>
[   24s]     lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
[   24s] /usr/lib/python3.10/site-packages/pluggy/_hooks.py:513: in __call__
[   24s]     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
[   24s] /usr/lib/python3.10/site-packages/pluggy/_manager.py:120: in _hookexec
[   24s]     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
[   24s] /usr/lib/python3.10/site-packages/_pytest/unraisableexception.py:90: in pytest_runtest_setup
[   24s]     yield from unraisable_exception_runtest_hook()
[   24s] /usr/lib/python3.10/site-packages/_pytest/unraisableexception.py:70: in unraisable_exception_runtest_hook
[   24s]     yield
[   24s] /usr/lib/python3.10/site-packages/_pytest/logging.py:842: in pytest_runtest_setup
[   24s]     yield from self._runtest_for(item, "setup")
[   24s] /usr/lib/python3.10/site-packages/_pytest/logging.py:831: in _runtest_for
[   24s]     yield
[   24s] /usr/lib/python3.10/site-packages/_pytest/capture.py:874: in pytest_runtest_setup
[   24s]     return (yield)
[   24s] /usr/lib/python3.10/site-packages/_pytest/threadexception.py:87: in pytest_runtest_setup
[   24s]     yield from thread_exception_runtest_hook()
[   24s] /usr/lib/python3.10/site-packages/_pytest/threadexception.py:68: in thread_exception_runtest_hook
[   24s]     yield
[   24s] /usr/lib/python3.10/site-packages/_pytest/runner.py:160: in pytest_runtest_setup
[   24s]     item.session._setupstate.setup(item)
[   24s] /usr/lib/python3.10/site-packages/_pytest/runner.py:514: in setup
[   24s]     col.setup()
[   24s] /usr/lib/python3.10/site-packages/_pytest/python.py:1630: in setup
[   24s]     self._request._fillfixtures()
[   24s] /usr/lib/python3.10/site-packages/_pytest/fixtures.py:696: in _fillfixtures
[   24s]     item.funcargs[argname] = self.getfixturevalue(argname)
[   24s] /usr/lib/python3.10/site-packages/_pytest/fixtures.py:531: in getfixturevalue
[   24s]     fixturedef = self._get_active_fixturedef(argname)
[   24s] /usr/lib/python3.10/site-packages/_pytest/fixtures.py:616: in _get_active_fixturedef
[   24s]     fixturedef.execute(request=subrequest)
[   24s] /usr/lib/python3.10/site-packages/_pytest/fixtures.py:1090: in execute
[   24s]     result = ihook.pytest_fixture_setup(fixturedef=self, request=request)
[   24s] /usr/lib/python3.10/site-packages/pluggy/_hooks.py:513: in __call__
[   24s]     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
[   24s] /usr/lib/python3.10/site-packages/pluggy/_manager.py:120: in _hookexec
[   24s]     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
[   24s] /usr/lib/python3.10/site-packages/pluggy/_callers.py:50: in _warn_teardown_exception
[   24s]     warnings.warn(PluggyTeardownRaisedWarning(msg), stacklevel=5)
[   24s] E   pluggy.PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
[   24s] E   Plugin: asyncio, Hook: pytest_fixture_setup
[   24s] E   DeprecationWarning: The event_loop fixture provided by pytest-asyncio has been redefined in
[   24s] E   /home/abuild/rpmbuild/BUILD/anthropic-0.33.1/tests/conftest.py:20
[   24s] E   Replacing the event_loop fixture with a custom implementation is deprecated
[   24s] E   and will lead to errors in the future.
[   24s] E   If you want to request an asyncio event loop with a scope other than function
[   24s] E   scope, use the "scope" argument to the asyncio mark when marking the tests.
[   24s] E   If you want to return different types of event loops, use the event_loop_policy
[   24s] E   fixture.
[   24s] E   
[   24s] E   For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning
[   24s] _ ERROR at teardown of test_extract_type_var_generic_subclass_different_ordering_multiple _
[   24s] /usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:815: in _close_event_loop
[   24s]     warnings.warn(
[   24s] E   DeprecationWarning: pytest-asyncio detected an unclosed event loop when tearing down the event_loop
[   24s] E   fixture: <_UnixSelectorEventLoop running=False closed=False debug=False>
[   24s] E   pytest-asyncio will close the event loop for you, but future versions of the
[   24s] E   library will no longer do so. In order to ensure compatibility with future
[   24s] E   versions, please make sure that:
[   24s] E       1. Any custom "event_loop" fixture properly closes the loop after yielding it
[   24s] E       2. The scopes of your custom "event_loop" fixtures do not overlap
[   24s] E       3. Your code does not modify the event loop in async fixtures or tests
[   24s] =================================== FAILURES ===================================
[   24s] _______________ TestAnthropic.test_proxies_option_is_deprecated ________________
[   24s] tests/test_client.py:700: in test_proxies_option_is_deprecated
[   24s]     with pytest.warns(
[   24s] E   DeprecationWarning: The 'proxies' argument is now deprecated. Use 'proxy' or 'mounts' instead.
[   24s] _____________ TestAsyncAnthropic.test_proxies_option_is_deprecated _____________
[   24s] tests/test_client.py:1588: in test_proxies_option_is_deprecated
[   24s]     with pytest.warns(
[   24s] E   DeprecationWarning: The 'proxies' argument is now deprecated. Use 'proxy' or 'mounts' instead.
[   24s] =========================== short test summary info ============================
[   24s] FAILED tests/test_client.py::TestAnthropic::test_proxies_option_is_deprecated
[   24s] FAILED tests/test_client.py::TestAsyncAnthropic::test_proxies_option_is_deprecated
[   24s] ERROR tests/lib/streaming/test_messages.py::TestAsyncMessages::test_basic_response
[   24s] ERROR tests/test_utils/test_typing.py::test_extract_type_var_generic_subclass_different_ordering_multiple
[   24s] =================== 2 failed, 318 passed, 2 errors in 7.63s ====================

In our case we are now using the following to suppress the error

Index: anthropic-0.33.1/pyproject.toml
===================================================================
--- anthropic-0.33.1.orig/pyproject.toml
+++ anthropic-0.33.1/pyproject.toml
@@ -142,7 +142,8 @@ addopts = "--tb=short"
 xfail_strict = true
 asyncio_mode = "auto"
 filterwarnings = [
-  "error"
+  "error",
+  "ignore::DeprecationWarning",
 ]

Out of curiosity is there any reason why you aren't using the same dependency versions we are? e.g. you could pip install -r requirements-dev.lock in the root of this repo