2023-12-31 22:37:21 +03:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
skip_openai = False
|
2024-01-22 06:17:59 -08:00
|
|
|
skip_redis = False
|
2024-02-04 07:08:14 -08:00
|
|
|
skip_docker = False
|
2024-04-15 05:34:26 -07:00
|
|
|
reason = "requested to skip"
|
2024-02-14 10:51:38 -08:00
|
|
|
MOCK_OPEN_AI_API_KEY = "sk-mockopenaiAPIkeyinexpectedformatfortestingonly"
|
|
|
|
|
2023-12-31 22:37:21 +03:00
|
|
|
|
2024-02-04 07:08:14 -08:00
|
|
|
# Registers command-line options like '--skip-openai' and '--skip-redis' via pytest hook.
|
2024-01-22 06:17:59 -08:00
|
|
|
# When these flags are set, it indicates that tests requiring OpenAI or Redis (respectively) should be skipped.
|
2023-12-31 22:37:21 +03:00
|
|
|
def pytest_addoption(parser):
|
|
|
|
parser.addoption("--skip-openai", action="store_true", help="Skip all tests that require openai")
|
2024-01-22 06:17:59 -08:00
|
|
|
parser.addoption("--skip-redis", action="store_true", help="Skip all tests that require redis")
|
2024-02-04 07:08:14 -08:00
|
|
|
parser.addoption("--skip-docker", action="store_true", help="Skip all tests that require docker")
|
2023-12-31 22:37:21 +03:00
|
|
|
|
|
|
|
|
2024-02-04 07:08:14 -08:00
|
|
|
# pytest hook implementation extracting command line args and exposing it globally
|
2023-12-31 22:37:21 +03:00
|
|
|
@pytest.hookimpl(tryfirst=True)
|
|
|
|
def pytest_configure(config):
|
|
|
|
global skip_openai
|
|
|
|
skip_openai = config.getoption("--skip-openai", False)
|
2024-01-20 09:06:29 -08:00
|
|
|
global skip_redis
|
|
|
|
skip_redis = config.getoption("--skip-redis", False)
|
2024-02-04 07:08:14 -08:00
|
|
|
global skip_docker
|
|
|
|
skip_docker = config.getoption("--skip-docker", False)
|