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