Raise errors when deprecated routes are used

This commit is contained in:
Jeremiah Lowin 2025-06-04 12:05:40 -04:00
commit 29eb9af467
6 changed files with 19 additions and 3 deletions

View file

@ -86,7 +86,7 @@ fallback-version = "0.0.0"
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "session"
asyncio_default_test_loop_scope = "session"
filterwarnings = []
filterwarnings = ["error::DeprecationWarning"]
timeout = 3
env = [
"FASTMCP_TEST_MODE=1",

View file

@ -0,0 +1,4 @@
import pytest
# reset deprecation warnings for this module
pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")

View file

@ -1,5 +1,3 @@
"""Tests for deprecated functionality."""
import warnings
from unittest.mock import AsyncMock, patch
@ -8,6 +6,9 @@ from starlette.applications import Starlette
from fastmcp import Client, FastMCP
# reset deprecation warnings for this module
pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
def test_sse_app_deprecation_warning():
"""Test that sse_app raises a deprecation warning."""

View file

@ -4,6 +4,9 @@ import pytest
from fastmcp import FastMCP
# reset deprecation warnings for this module
pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
def test_mount_tool_separator_deprecation_warning():
"""Test that using tool_separator in mount() raises a deprecation warning."""

View file

@ -1,5 +1,7 @@
"""Tests for legacy resource prefix behavior."""
import pytest
from fastmcp import Client, FastMCP
from fastmcp.server.server import (
add_resource_prefix,
@ -8,6 +10,9 @@ from fastmcp.server.server import (
)
from fastmcp.utilities.tests import temporary_settings
# reset deprecation warnings for this module
pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
class TestLegacyResourcePrefixes:
"""Test the legacy resource prefix behavior."""

View file

@ -12,6 +12,9 @@ from fastmcp.server.openapi import (
RouteType,
)
# reset deprecation warnings for this module
pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
def test_route_type_ignore_deprecation_warning():
"""Test that using RouteType.IGNORE emits a deprecation warning."""