From f3c4d207a7b5b0ecb14847a3253d6050456461cf Mon Sep 17 00:00:00 2001 From: Joe Dinius Date: Fri, 11 Oct 2024 12:29:09 -0700 Subject: [PATCH] Catch expected pytest warning about invalid COT_URL Running the suite of pytest tests yields a single warning: ``` tests/test_client_functions.py::test_protocol_factory_bad_url Warning: Invalid COT_URL=udp:localhost ``` Based on the context of the test, this warning shouldn't be flagged as a warning at all. The warning is expected. This commit explicitly catches the expected warning from pytest and marks the test as an unconditional pass. --- tests/test_client_functions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_client_functions.py b/tests/test_client_functions.py index 47aeb95..35362a6 100644 --- a/tests/test_client_functions.py +++ b/tests/test_client_functions.py @@ -145,8 +145,9 @@ async def test_protocol_factory_bad_url(): """Test calling `pytak.protocol_factory()` with a bad URL.""" test_url1: str = "udp:localhost" config: dict = {"COT_URL": test_url1} - with pytest.raises(Exception): - await pytak.protocol_factory(config) + with pytest.warns(SyntaxWarning, match="Invalid COT_URL"): + with pytest.raises(Exception): + await pytak.protocol_factory(config) @pytest.mark.asyncio