From 4d08a4467dfac1fb098b513e202b0170b515dac0 Mon Sep 17 00:00:00 2001 From: Username Date: Mon, 22 Dec 2025 20:06:51 +0100 Subject: [PATCH] fix: conditional requests import in container tests --- tests/test_container_integration.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_container_integration.py b/tests/test_container_integration.py index a1edbbf..d5b9116 100644 --- a/tests/test_container_integration.py +++ b/tests/test_container_integration.py @@ -20,7 +20,15 @@ import subprocess import time import pytest -import requests + +# Skip module entirely if integration tests are disabled +# This allows the file to be collected without requiring 'requests' +_INTEGRATION_ENABLED = bool(os.environ.get("FLASKPASTE_INTEGRATION")) + +if _INTEGRATION_ENABLED: + import requests +else: + requests = None # type: ignore[assignment] # Configuration CONTAINER_NAME = "flaskpaste-test" @@ -47,7 +55,7 @@ def should_run_integration_tests() -> bool: Integration tests only run when FLASKPASTE_INTEGRATION=1 environment variable is set AND a container runtime is available. """ - if not os.environ.get("FLASKPASTE_INTEGRATION"): + if not _INTEGRATION_ENABLED: return False return get_container_runtime() is not None