Skip to content

Commit 46cf8af

Browse files
authored
Add timeouts to tests (#266)
1 parent 291768b commit 46cf8af

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ dev = [
5252
"pytest-asyncio",
5353
"pytest-forked",
5454
"pytest-markdown-docs",
55+
"pytest-timeout",
5556
"ruff",
5657
"sphinx-autobuild",
5758
"sphinx-copybutton",
@@ -93,6 +94,7 @@ addopts = """
9394
# filterwarnings = "error"
9495
# Doctest python code in docs, python code in src docstrings, test functions in tests
9596
testpaths = "docs src tests"
97+
timeout = 1
9698

9799
[tool.coverage.run]
98100
data_file = "/tmp/fastcs.coverage"

tests/test_docs_snippets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def sim_temperature_controller():
3737
print(process.communicate()[0])
3838

3939

40+
@pytest.mark.timeout(3)
4041
@pytest.mark.parametrize("filename", glob.glob("docs/snippets/*.py", recursive=True))
4142
def test_snippet(filename):
4243
runpy.run_path(filename)

tests/transport/epics/ca/test_softioc_system.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from multiprocessing import Queue
22

3+
import pytest
34
from p4p import Value
45
from p4p.client.thread import Context
56

67

8+
@pytest.mark.timeout(3)
79
def test_ioc(softioc_subprocess: tuple[str, Queue]):
810
pv_prefix, _ = softioc_subprocess
911
ctxt = Context("pva")

tests/transport/epics/pva/test_p4p.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424

2525
@pytest.mark.asyncio
26+
@pytest.mark.timeout(2)
2627
async def test_ioc(p4p_subprocess: tuple[str, Queue]):
2728
pv_prefix, _ = p4p_subprocess
2829
ctxt = Context("pva")
@@ -74,6 +75,7 @@ async def test_ioc(p4p_subprocess: tuple[str, Queue]):
7475

7576

7677
@pytest.mark.asyncio
78+
@pytest.mark.timeout(5)
7779
async def test_scan_method(p4p_subprocess: tuple[str, Queue]):
7880
pv_prefix, _ = p4p_subprocess
7981
ctxt = Context("pva")
@@ -113,6 +115,7 @@ async def test_scan_method(p4p_subprocess: tuple[str, Queue]):
113115

114116

115117
@pytest.mark.asyncio
118+
@pytest.mark.timeout(2)
116119
async def test_command_method(p4p_subprocess: tuple[str, Queue]):
117120
pv_prefix, _ = p4p_subprocess
118121
d_values = asyncio.Queue()
@@ -174,6 +177,7 @@ async def test_command_method(p4p_subprocess: tuple[str, Queue]):
174177

175178

176179
@pytest.mark.asyncio
180+
@pytest.mark.timeout(2)
177181
async def test_numerical_alarms(p4p_subprocess: tuple[str, Queue]):
178182
pv_prefix, _ = p4p_subprocess
179183
a_values = asyncio.Queue()
@@ -535,6 +539,7 @@ async def _wait_and_put_pvs():
535539
)
536540

537541

542+
@pytest.mark.timeout(4)
538543
def test_command_method_put_twice(caplog):
539544
class SomeController(Controller):
540545
command_runs_for_a_while_times = []

0 commit comments

Comments
 (0)