fix: conditional requests import in container tests
This commit is contained in:
@@ -20,7 +20,15 @@ import subprocess
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
import pytest
|
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
|
# Configuration
|
||||||
CONTAINER_NAME = "flaskpaste-test"
|
CONTAINER_NAME = "flaskpaste-test"
|
||||||
@@ -47,7 +55,7 @@ def should_run_integration_tests() -> bool:
|
|||||||
Integration tests only run when FLASKPASTE_INTEGRATION=1 environment
|
Integration tests only run when FLASKPASTE_INTEGRATION=1 environment
|
||||||
variable is set AND a container runtime is available.
|
variable is set AND a container runtime is available.
|
||||||
"""
|
"""
|
||||||
if not os.environ.get("FLASKPASTE_INTEGRATION"):
|
if not _INTEGRATION_ENABLED:
|
||||||
return False
|
return False
|
||||||
return get_container_runtime() is not None
|
return get_container_runtime() is not None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user