From d5a0117cfb1806e7b16808829ceb8c99095f58c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Tue, 23 Apr 2024 09:31:08 +0200 Subject: [PATCH] Use mock patch instead of ghetto monkey patch --- api/tests/unit/test_probe_services.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/tests/unit/test_probe_services.py b/api/tests/unit/test_probe_services.py index dfd3580e..96d1f475 100644 --- a/api/tests/unit/test_probe_services.py +++ b/api/tests/unit/test_probe_services.py @@ -1,11 +1,12 @@ -from unittest.mock import MagicMock, Mock +from unittest.mock import patch import ooniapi.probe_services from ooniapi.probe_services import random_web_test_helpers, round_robin_web_test_helpers -def test_web_test_helpers(): - ooniapi.probe_services.extract_probe_ipaddr = Mock(return_value="1.2.3.4") +@patch("ooniapi.probe_services.extract_probe_ipaddr") +def test_web_test_helpers(mock): + mock.return_value = "1.2.3.4" r1 = random_web_test_helpers( [ "https://0.th.ooni.org",