"""测试 TextResourceContentsWithContent 类的完整覆盖."""
import pytest
from src.server import TextResourceContentsWithContent
class TestTextResourceContentsWithContent:
"""测试 TextResourceContentsWithContent 类的所有方法."""
def test_content_attribute(self):
"""测试 content 属性(覆盖第40-41行)."""
obj = TextResourceContentsWithContent(uri="test://uri", text="test content")
assert obj.content == "test content"
assert obj.text == "test content"
def test_mime_type_attribute(self):
"""测试 mime_type 属性(覆盖第42-43行)."""
obj = TextResourceContentsWithContent(uri="test://uri", text="test", mimeType="text/plain")
assert obj.mime_type == "text/plain"
def test_mime_type_attribute_none(self):
"""测试 mime_type 属性为 None(覆盖第42-43行)."""
obj = TextResourceContentsWithContent(uri="test://uri", text="test")
assert obj.mime_type is None
def test_getattr_unknown_attribute(self):
"""测试未知属性(覆盖第44行)."""
obj = TextResourceContentsWithContent(uri="test://uri", text="test")
with pytest.raises(AttributeError, match="'TextResourceContentsWithContent' object has no attribute 'unknown'"):
_ = obj.unknown