diff --git a/pyproject.toml b/pyproject.toml index def3a598d..a6ccbc4d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,6 +52,7 @@ dev = [ "pytest-asyncio", "pytest-forked", "pytest-markdown-docs", + "pytest-timeout", "ruff", "sphinx-autobuild", "sphinx-copybutton", @@ -93,6 +94,7 @@ addopts = """ # filterwarnings = "error" # Doctest python code in docs, python code in src docstrings, test functions in tests testpaths = "docs src tests" +timeout = 1 [tool.coverage.run] data_file = "/tmp/fastcs.coverage" diff --git a/tests/test_docs_snippets.py b/tests/test_docs_snippets.py index 3d2aaaf5c..799613235 100644 --- a/tests/test_docs_snippets.py +++ b/tests/test_docs_snippets.py @@ -37,6 +37,7 @@ def sim_temperature_controller(): print(process.communicate()[0]) +@pytest.mark.timeout(3) @pytest.mark.parametrize("filename", glob.glob("docs/snippets/*.py", recursive=True)) def test_snippet(filename): runpy.run_path(filename) diff --git a/tests/transport/epics/ca/test_softioc_system.py b/tests/transport/epics/ca/test_softioc_system.py index bda71d54d..c823352a9 100644 --- a/tests/transport/epics/ca/test_softioc_system.py +++ b/tests/transport/epics/ca/test_softioc_system.py @@ -1,9 +1,11 @@ from multiprocessing import Queue +import pytest from p4p import Value from p4p.client.thread import Context +@pytest.mark.timeout(3) def test_ioc(softioc_subprocess: tuple[str, Queue]): pv_prefix, _ = softioc_subprocess ctxt = Context("pva") diff --git a/tests/transport/epics/pva/test_p4p.py b/tests/transport/epics/pva/test_p4p.py index 2c2ed855c..9ad4ec42c 100644 --- a/tests/transport/epics/pva/test_p4p.py +++ b/tests/transport/epics/pva/test_p4p.py @@ -23,6 +23,7 @@ @pytest.mark.asyncio +@pytest.mark.timeout(2) async def test_ioc(p4p_subprocess: tuple[str, Queue]): pv_prefix, _ = p4p_subprocess ctxt = Context("pva") @@ -74,6 +75,7 @@ async def test_ioc(p4p_subprocess: tuple[str, Queue]): @pytest.mark.asyncio +@pytest.mark.timeout(5) async def test_scan_method(p4p_subprocess: tuple[str, Queue]): pv_prefix, _ = p4p_subprocess ctxt = Context("pva") @@ -113,6 +115,7 @@ async def test_scan_method(p4p_subprocess: tuple[str, Queue]): @pytest.mark.asyncio +@pytest.mark.timeout(2) async def test_command_method(p4p_subprocess: tuple[str, Queue]): pv_prefix, _ = p4p_subprocess d_values = asyncio.Queue() @@ -174,6 +177,7 @@ async def test_command_method(p4p_subprocess: tuple[str, Queue]): @pytest.mark.asyncio +@pytest.mark.timeout(2) async def test_numerical_alarms(p4p_subprocess: tuple[str, Queue]): pv_prefix, _ = p4p_subprocess a_values = asyncio.Queue() @@ -535,6 +539,7 @@ async def _wait_and_put_pvs(): ) +@pytest.mark.timeout(4) def test_command_method_put_twice(caplog): class SomeController(Controller): command_runs_for_a_while_times = []