From 5b39f70aa14cac635b6084170e9d0bd3f548b911 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Mon, 10 Aug 2026 20:00:28 +0200 Subject: test: simplify mocks and localize test fixtures Replace shared HTTPX and DNS fixtures with targeted unittest.mock patches close to the tests that need them. Keep conftest focused on application and client setup, while moving receiver-specific helpers into the receiver test module. --- tests/test_forms.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests/test_forms.py') diff --git a/tests/test_forms.py b/tests/test_forms.py index 2d5fc01..417c655 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -1,3 +1,5 @@ +from unittest.mock import patch + import pytest from flask import Flask from werkzeug.datastructures import MultiDict @@ -8,6 +10,10 @@ VALID_SOURCE = "https://source.example/post" VALID_TARGET = "https://dennisfink.me/blog/example/" +@patch( + "webmentions_ssg.forms.validators.ensure_public_url", + new=lambda url: None, +) @pytest.mark.parametrize( ( "form_data", @@ -89,7 +95,6 @@ VALID_TARGET = "https://dennisfink.me/blog/example/" ) def test_endpoint_form_rejects_invalid_data( app: Flask, - public_dns: None, form_data: dict[str, str], invalid_field: str, expected_error: str | None, @@ -110,9 +115,12 @@ def test_endpoint_form_rejects_invalid_data( assert expected_error in form.errors[invalid_field] +@patch( + "webmentions_ssg.forms.validators.ensure_public_url", + new=lambda url: None, +) def test_endpoint_form_accepts_valid_data( app: Flask, - public_dns: None, ) -> None: with app.test_request_context( "/endpoint", -- cgit v1.3.1