Skip to content

Tests fail with Pydantic 2.11 #462

Closed
@medaminezghal

Description

@medaminezghal
_________________________________ test_desktop _________________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7e6a84db5a90>

    @pytest.mark.anyio
    async def test_desktop(monkeypatch):
        """Test the desktop server"""
        from pathlib import Path
    
        from pydantic import AnyUrl
    
        from examples.fastmcp.desktop import mcp
    
        # Mock desktop directory listing
        mock_files = [Path("/fake/path/file1.txt"), Path("/fake/path/file2.txt")]
        monkeypatch.setattr(Path, "iterdir", lambda self: mock_files)
        monkeypatch.setattr(Path, "home", lambda: Path("/fake/home"))
    
        async with client_session(mcp._mcp_server) as client:
            # Test the add function
            result = await client.call_tool("add", {"a": 1, "b": 2})
            assert len(result.content) == 1
            content = result.content[0]
            assert isinstance(content, TextContent)
>           assert content.text == "3"
E           assert "Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0." == '3'
E             
E             - 3
E             + Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.

tests/test_examples.py:64: AssertionError

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/memory.py", line 100, in create_connected_server_and_client_session
  File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/tests/test_examples.py", line 64, in test_desktop
    assert content.text == "3"
AssertionError: assert "Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0." == '3'
  
  - 3
  + Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.

During handling of the above exception, another exception occurred:

  + Exception Group Traceback (most recent call last):
  |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/memory.py", line 90, in create_connected_server_and_client_session
  |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/session.py", line 210, in __aexit__
  |   File "/usr/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 767, in __aexit__
  |     raise BaseExceptionGroup(
  |         "unhandled errors in a TaskGroup", self._exceptions
  |     )
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/memory.py", line 100, in create_connected_server_and_client_session
    |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/tests/test_examples.py", line 64, in test_desktop
    |     assert content.text == "3"
    | AssertionError: assert "Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0." == '3'
    |   
    |   - 3
    |   + Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
    +------------------------------------

During handling of the above exception, another exception occurred:
  + Exception Group Traceback (most recent call last):
  |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/memory.py", line 90, in create_connected_server_and_client_session
  |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/session.py", line 210, in __aexit__
  |   File "/usr/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 767, in __aexit__
  |     raise BaseExceptionGroup(
  |         "unhandled errors in a TaskGroup", self._exceptions
  |     )
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/memory.py", line 100, in create_connected_server_and_client_session
    |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/tests/test_examples.py", line 64, in test_desktop
    |     assert content.text == "3"
    | AssertionError: assert "Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0." == '3'
    |   
    |   - 3
    |   + Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
    +------------------------------------

During handling of the above exception, another exception occurred:

  + Exception Group Traceback (most recent call last):
  |   File "/usr/lib/python3.13/site-packages/_pytest/runner.py", line 341, in from_call
  |     result: TResult | None = func()
  |                              ~~~~^^
  |   File "/usr/lib/python3.13/site-packages/flaky/flaky_pytest_plugin.py", line 146, in <lambda>
  |     lambda: ihook(item=item, **kwds), when=when, reraise=reraise
  |             ~~~~~^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/pluggy/_hooks.py", line 513, in __call__
  |     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  |            ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/pluggy/_manager.py", line 120, in _hookexec
  |     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  |            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/pluggy/_callers.py", line 182, in _multicall
  |     return outcome.get_result()
  |            ~~~~~~~~~~~~~~~~~~^^
  |   File "/usr/lib/python3.13/site-packages/pluggy/_result.py", line 100, in get_result
  |     raise exc.with_traceback(exc.__traceback__)
  |   File "/usr/lib/python3.13/site-packages/pluggy/_callers.py", line 167, in _multicall
  |     teardown.throw(outcome._exception)
  |     ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/_pytest/threadexception.py", line 92, in pytest_runtest_call
  |     yield from thread_exception_runtest_hook()
  |   File "/usr/lib/python3.13/site-packages/_pytest/threadexception.py", line 68, in thread_exception_runtest_hook
  |     yield
  |   File "/usr/lib/python3.13/site-packages/pluggy/_callers.py", line 167, in _multicall
  |     teardown.throw(outcome._exception)
  |     ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/_pytest/unraisableexception.py", line 95, in pytest_runtest_call
  |     yield from unraisable_exception_runtest_hook()
  |   File "/usr/lib/python3.13/site-packages/_pytest/unraisableexception.py", line 70, in unraisable_exception_runtest_hook
  |     yield
  |   File "/usr/lib/python3.13/site-packages/pluggy/_callers.py", line 167, in _multicall
  |     teardown.throw(outcome._exception)
  |     ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/_pytest/logging.py", line 846, in pytest_runtest_call
  |     yield from self._runtest_for(item, "call")
  |   File "/usr/lib/python3.13/site-packages/_pytest/logging.py", line 829, in _runtest_for
  |     yield
  |   File "/usr/lib/python3.13/site-packages/pluggy/_callers.py", line 167, in _multicall
  |     teardown.throw(outcome._exception)
  |     ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/_pytest/capture.py", line 898, in pytest_runtest_call
  |     return (yield)
  |             ^^^^^
  |   File "/usr/lib/python3.13/site-packages/pluggy/_callers.py", line 167, in _multicall
  |     teardown.throw(outcome._exception)
  |     ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/_pytest/skipping.py", line 257, in pytest_runtest_call
  |     return (yield)
  |             ^^^^^
  |   File "/usr/lib/python3.13/site-packages/pluggy/_callers.py", line 103, in _multicall
  |     res = hook_impl.function(*args)
  |   File "/usr/lib/python3.13/site-packages/_pytest/runner.py", line 174, in pytest_runtest_call
  |     item.runtest()
  |     ~~~~~~~~~~~~^^
  |   File "/usr/lib/python3.13/site-packages/_pytest/python.py", line 1627, in runtest
  |     self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/pluggy/_hooks.py", line 513, in __call__
  |     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  |            ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/pluggy/_manager.py", line 120, in _hookexec
  |     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  |            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/pluggy/_callers.py", line 182, in _multicall
  |     return outcome.get_result()
  |            ~~~~~~~~~~~~~~~~~~^^
  |   File "/usr/lib/python3.13/site-packages/pluggy/_result.py", line 100, in get_result
  |     raise exc.with_traceback(exc.__traceback__)
  |   File "/usr/lib/python3.13/site-packages/pluggy/_callers.py", line 103, in _multicall
  |     res = hook_impl.function(*args)
  |   File "/usr/lib/python3.13/site-packages/anyio/pytest_plugin.py", line 160, in pytest_pyfunc_call
  |     runner.run_test(pyfuncitem.obj, testargs)
  |     ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2272, in run_test
  |     self._raise_async_exceptions()
  |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  |   File "/usr/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2176, in _raise_async_exceptions
  |     raise exceptions[0]
  |   File "/usr/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2266, in run_test
  |     self.get_loop().run_until_complete(
  |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
  |         self._call_in_runner_task(test_func, **kwargs)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |     )
  |     ^
  |   File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
  |     return future.result()
  |            ~~~~~~~~~~~~~^^
  |   File "/usr/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2226, in _call_in_runner_task
  |     return await future
  |            ^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2193, in _run_tests_and_fixtures
  |     retval = await coro
  |              ^^^^^^^^^^
  |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/tests/test_examples.py", line 58, in test_desktop
  |     async with client_session(mcp._mcp_server) as client:
  |                ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.13/contextlib.py", line 235, in __aexit__
  |     await self.gen.athrow(value)
  |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/memory.py", line 79, in create_connected_server_and_client_session
  |   File "/usr/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 767, in __aexit__
  |     raise BaseExceptionGroup(
  |         "unhandled errors in a TaskGroup", self._exceptions
  |     )
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/memory.py", line 100, in create_connected_server_and_client_session
    |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/tests/test_examples.py", line 64, in test_desktop
    |     assert content.text == "3"
    | AssertionError: assert "Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0." == '3'
    |   
    |   - 3
    |   + Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
    | 
    | During handling of the above exception, another exception occurred:
    | 
    | Exception Group Traceback (most recent call last):
    |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/memory.py", line 90, in create_connected_server_and_client_session
    |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/session.py", line 210, in __aexit__
    |   File "/usr/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 767, in __aexit__
    |     raise BaseExceptionGroup(
    |         "unhandled errors in a TaskGroup", self._exceptions
    |     )
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
      | Traceback (most recent call last):
      |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/test-env/lib/python3.13/site-packages/mcp/shared/memory.py", line 100, in create_connected_server_and_client_session
      |   File "/home/medaminezghal/Documents/AUR_Packages/python-mcp/test/src/mcp-1.6.0/tests/test_examples.py", line 64, in test_desktop
      |     assert content.text == "3"
      | AssertionError: assert "Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0." == '3'
      |   
      |   - 3
      |   + Error executing tool add: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
      +------------------------------------

Same error happens for 34 tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions