diff --git a/tests/integrations/beam/test_beam.py b/tests/integrations/beam/test_beam.py index e80a67a107..ae93d0a672 100644 --- a/tests/integrations/beam/test_beam.py +++ b/tests/integrations/beam/test_beam.py @@ -140,17 +140,13 @@ def test_monkey_patch_signature(f, args, kwargs): except Exception: print("Failed on {} with parameters {}, {}".format(f_temp, args, kwargs)) raise - try: - expected_signature = inspect.signature(f) - test_signature = inspect.signature(f_temp) - assert expected_signature == test_signature, ( - "Failed on {}, signature {} does not match {}".format( - f, expected_signature, test_signature - ) + expected_signature = inspect.signature(f) + test_signature = inspect.signature(f_temp) + assert expected_signature == test_signature, ( + "Failed on {}, signature {} does not match {}".format( + f, expected_signature, test_signature ) - except Exception: - # expected to pass for py2.7 - pass + ) class _OutputHandler(OutputHandler): diff --git a/tests/integrations/grpc/test_grpc.py b/tests/integrations/grpc/test_grpc.py index e5a19f2f1c..0c983c9960 100644 --- a/tests/integrations/grpc/test_grpc.py +++ b/tests/integrations/grpc/test_grpc.py @@ -666,8 +666,7 @@ def test_stream_stream(sentry_init): # Use the provided channel stub = gRPCTestServiceStub(channel) response_iterator = stub.TestStreamStream(iter((gRPCTestMessage(text="test"),))) - for response in response_iterator: - assert response.text == "test" + assert [response.text for response in response_iterator] == ["test"] _tear_down(server=server) diff --git a/tests/integrations/grpc/test_grpc_aio.py b/tests/integrations/grpc/test_grpc_aio.py index ae8cd72791..9257a7504e 100644 --- a/tests/integrations/grpc/test_grpc_aio.py +++ b/tests/integrations/grpc/test_grpc_aio.py @@ -453,8 +453,7 @@ async def test_stream_stream(grpc_server_and_channel): # Use the provided channel stub = gRPCTestServiceStub(channel) response = stub.TestStreamStream((gRPCTestMessage(text="test"),)) - async for r in response: - assert r.text == "test" + assert [r.text async for r in response] == ["test"] @pytest.mark.asyncio diff --git a/tests/integrations/mcp/test_mcp.py b/tests/integrations/mcp/test_mcp.py index 15432d8d84..ef6c04bbdb 100644 --- a/tests/integrations/mcp/test_mcp.py +++ b/tests/integrations/mcp/test_mcp.py @@ -142,21 +142,21 @@ def __init__(self, text): self.text = text +@pytest.mark.skipif(IS_MCP_V2, reason="Server decorator patching is MCP v1 only") def test_integration_patches_server(sentry_init): """Test that MCPIntegration patches the Server class""" - if not IS_MCP_V2: - original_call_tool = Server.call_tool - original_get_prompt = Server.get_prompt - original_read_resource = Server.read_resource + original_call_tool = Server.call_tool + original_get_prompt = Server.get_prompt + original_read_resource = Server.read_resource - sentry_init( - integrations=[MCPIntegration()], - traces_sample_rate=1.0, - ) + sentry_init( + integrations=[MCPIntegration()], + traces_sample_rate=1.0, + ) - assert Server.call_tool is not original_call_tool - assert Server.get_prompt is not original_get_prompt - assert Server.read_resource is not original_read_resource + assert Server.call_tool is not original_call_tool + assert Server.get_prompt is not original_get_prompt + assert Server.read_resource is not original_read_resource @pytest.mark.asyncio diff --git a/tests/integrations/pydantic_ai/test_pydantic_ai.py b/tests/integrations/pydantic_ai/test_pydantic_ai.py index e100e62671..c67a399d40 100644 --- a/tests/integrations/pydantic_ai/test_pydantic_ai.py +++ b/tests/integrations/pydantic_ai/test_pydantic_ai.py @@ -3591,15 +3591,8 @@ async def test_tool_execution_without_span_context(sentry_init, capture_items): # Call without span context (no transaction active) # The patches should handle this gracefully - try: - # This will fail because we're not in a transaction, but it should not crash - await agent.run("test") - except Exception: - # Expected to fail, that's okay - pass - - # Should not crash - assert True + result = await agent.run("test") + assert result.output is not None @pytest.mark.asyncio diff --git a/tests/test_client.py b/tests/test_client.py index 7dc3922285..207d6b7590 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1038,20 +1038,8 @@ def custom_repr(value): assert "Fail object" in my_vars["fail"] -@pytest.mark.parametrize( - "dsn", - [ - "http://894b7d594095440f8dfea9b300e6f572@localhost:8000/2", - "http://894b7d594095440f8dfea9b300e6f572@localhost:8000/2", - ], -) -def test_init_string_types(dsn, sentry_init): - # Allow unicode strings on Python 3 and both on Python 2 (due to - # unicode_literals) - # - # Supporting bytes on Python 3 is not really wrong but probably would be - # extra code - sentry_init(dsn) +def test_init_string_types(sentry_init): + sentry_init("http://894b7d594095440f8dfea9b300e6f572@localhost:8000/2") assert ( sentry_sdk.get_client().dsn == "http://894b7d594095440f8dfea9b300e6f572@localhost:8000/2" diff --git a/tests/test_envelope.py b/tests/test_envelope.py index 5549cc6e36..3fd5a9fbfa 100644 --- a/tests/test_envelope.py +++ b/tests/test_envelope.py @@ -73,9 +73,8 @@ def test_add_and_get_session(): expected = Session() envelope.add_session(expected) - for item in envelope: - if item.type == "session": - assert item.payload.json == expected.to_json() + (item,) = [item for item in envelope if item.type == "session"] + assert item.payload.json == expected.to_json() def test_envelope_headers(sentry_init, capture_envelopes, monkeypatch): diff --git a/tests/test_utils.py b/tests/test_utils.py index 8b39a1056e..b196c70a30 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -835,7 +835,6 @@ def test_parse_version(version, expected_result): ), False, ), - ("1.0.1", (2, 0, 0), False), ("2.0", (1,), True), ( "2.0.1",