From 967d54e93f942c33b945e2bde6e8df0d4f8bc094 Mon Sep 17 00:00:00 2001 From: Cserna Zsolt Date: Sun, 11 Aug 2024 23:10:43 +0200 Subject: [PATCH] tests: add test for log leak This is fixed in #352, and here is the test for it. --- tests/test_log_leak.py | 29 +++++++++++++++++++++++++++++ tests/test_release.py | 1 + 2 files changed, 30 insertions(+) create mode 100644 tests/test_log_leak.py diff --git a/tests/test_log_leak.py b/tests/test_log_leak.py new file mode 100644 index 00000000..fa6ffcfd --- /dev/null +++ b/tests/test_log_leak.py @@ -0,0 +1,29 @@ +import pytest +import requests + +from pytest_httpserver import HTTPServer + + +class Client: + def __init__(self) -> None: + self.url: str | None = None + + def get(self): + if self.url: + requests.get(self.url) + + +@pytest.fixture() +def my_fixture(): + client = Client() + yield client + client.get() + + +def test_1(my_fixture: Client, httpserver: HTTPServer): + httpserver.expect_request("/foo").respond_with_data("OK") + my_fixture.url = httpserver.url_for("/foo") + + +def test_2(httpserver: HTTPServer): + assert httpserver.log == [] diff --git a/tests/test_release.py b/tests/test_release.py index ada1e782..4f8d2420 100644 --- a/tests/test_release.py +++ b/tests/test_release.py @@ -212,6 +212,7 @@ def test_sdist_contents(build: Build, version: str): "test_hooks.py", "test_ip_protocols.py", "test_json_matcher.py", + "test_log_leak.py", "test_log_querying.py", "test_mixed.py", "test_oneshot.py",