From cdc6582a8f5a868713e5fe643d39aa21b8a79c4f Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Mon, 23 Feb 2026 14:51:19 -0500 Subject: [PATCH] fix: add timeouts to PayPal sandbox tests and pytest-timeout safety net PayPal sandbox tests used requests.post/get() with no timeout parameter. When the CI runner at build.unturf.com cannot reach api-m.sandbox.paypal.com, these calls block until TCP timeout (minutes), stalling all xdist workers and causing the 1-hour CI timeout. - Add timeout=10 to all requests calls in PayPal sandbox tests - Add pytest-timeout with 60s default so no single test can hang the suite --- make_post_sell/tests/test_functional.py | 18 ++++++++++++------ pytest.ini | 1 + requirements-test.txt | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/make_post_sell/tests/test_functional.py b/make_post_sell/tests/test_functional.py index 66fe211..d75abd0 100644 --- a/make_post_sell/tests/test_functional.py +++ b/make_post_sell/tests/test_functional.py @@ -1773,7 +1773,8 @@ class AuthenticatedFunctionalTests(FunctionalTests): f"{base_url}/v1/oauth2/token", headers={"Accept": "application/json", "Accept-Language": "en_US"}, data={"grant_type": "client_credentials"}, - auth=(paypal_client_id, paypal_secret) + auth=(paypal_client_id, paypal_secret), + timeout=10, ) self.assertEqual(auth_response.status_code, 200) @@ -1803,7 +1804,8 @@ class AuthenticatedFunctionalTests(FunctionalTests): f"{base_url}/v1/oauth2/token", headers={"Accept": "application/json", "Accept-Language": "en_US"}, data={"grant_type": "client_credentials"}, - auth=(paypal_client_id, paypal_secret) + auth=(paypal_client_id, paypal_secret), + timeout=10, ) self.assertEqual(auth_response.status_code, 200) @@ -1827,7 +1829,8 @@ class AuthenticatedFunctionalTests(FunctionalTests): "Content-Type": "application/json", "Authorization": f"Bearer {access_token}" }, - json=order_json + json=order_json, + timeout=10, ) self.assertEqual(order_response.status_code, 201) @@ -1943,7 +1946,8 @@ class AuthenticatedFunctionalTests(FunctionalTests): f"{base_url}/v1/oauth2/token", headers={"Accept": "application/json", "Accept-Language": "en_US"}, data={"grant_type": "client_credentials"}, - auth=(paypal_client_id, paypal_secret) + auth=(paypal_client_id, paypal_secret), + timeout=10, ) access_token = auth_response.json()["access_token"] @@ -1961,7 +1965,8 @@ class AuthenticatedFunctionalTests(FunctionalTests): "amount": {"currency_code": "USD", "value": "5.00"}, "description": "Test retrieval order" }] - } + }, + timeout=10, ) order_id = order_response.json()["id"] @@ -1969,7 +1974,8 @@ class AuthenticatedFunctionalTests(FunctionalTests): # Retrieve the order get_response = requests.get( f"{base_url}/v2/checkout/orders/{order_id}", - headers={"Authorization": f"Bearer {access_token}"} + headers={"Authorization": f"Bearer {access_token}"}, + timeout=10, ) self.assertEqual(get_response.status_code, 200) diff --git a/pytest.ini b/pytest.ini index 42f96ff..7e66d1d 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,6 +1,7 @@ [pytest] testpaths = make_post_sell python_files = test*.py +timeout = 60 # Uncomment filterwarnings to suppress external library warnings # filterwarnings = # # Ignore datetime.utcnow() deprecation from external libraries diff --git a/requirements-test.txt b/requirements-test.txt index 76b59ed..ec3ddfd 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,6 +1,7 @@ # testing. pytest pytest-cov +pytest-timeout # Per-test timeout safety net pytest-xdist # Parallel test execution nose mock