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