47 lines
1.2 KiB
Python
Executable File
47 lines
1.2 KiB
Python
Executable File
import time
|
|
|
|
from caproto.sync.client import read, write
|
|
import pytest
|
|
|
|
from common import read_config
|
|
|
|
TIMEOUT_READ = 2
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def check_ioc_running():
|
|
|
|
config = read_config()
|
|
pvprefix = config['pvprefix']
|
|
|
|
"""
|
|
This function checks if the test IOC is already running.
|
|
"""
|
|
try:
|
|
read(f'{pvprefix}:IOCREADY', timeout=TIMEOUT_READ)
|
|
|
|
# Reading the check recird was successfull -> We assume that the IOC
|
|
# is running
|
|
return
|
|
except TimeoutError:
|
|
# IOC startup failed in the given time -> Raise an error
|
|
raise Exception('Start the test IOC first ()')
|
|
|
|
def pytest_addoption(parser):
|
|
"""
|
|
This function adds the --stress flag to Pytest which can be given to
|
|
perform long-running stress tests.
|
|
"""
|
|
parser.addoption(
|
|
"--stresstest",
|
|
action="store_true",
|
|
default=False,
|
|
help="Run tests marked as stresstest"
|
|
)
|
|
|
|
def pytest_runtest_setup(item):
|
|
"""
|
|
This function provides a marker which can be used on test functions to
|
|
mark them as stress tests via `@pytest.mark.stresstest`.
|
|
"""
|
|
if 'stresstest' in item.keywords and not item.config.getoption("--stresstest"):
|
|
pytest.skip("Need --stress to run this test") |