Skip to content

Commit 3b1999c

Browse files
committed
fix(tests): Add Pytest timeout mark.
Adding `@pytest.mark.timeout()` to individual tests, modules, or classes to prevent tests to fail due to non reponsive tests. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
1 parent d0c474d commit 3b1999c

4 files changed

Lines changed: 6 additions & 0 deletions

File tree

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ jobs:
280280
parameters:
281281
docker:
282282
- image: ghcr.io/pvital/pvital-python:latest
283+
environment:
284+
PYTEST_TIMEOUT: 60
283285
- image: public.ecr.aws/docker/library/postgres:16.10-trixie
284286
environment:
285287
POSTGRES_USER: root

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[pytest]
2+
timeout = 60
23
log_cli = 1
34
log_cli_level = WARN
45
log_cli_format = %(asctime)s %(levelname)s %(message)s
@@ -10,3 +11,4 @@ testpaths =
1011
tests_autowrapt
1112
markers =
1213
original: mark test to use the original method instead of the mocked ones under `conftest.py`
14+

tests/clients/test_google-cloud-pubsub.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def _resource(self) -> Generator[None, None, None]:
157157
request={"subscription": self.subscription_path}
158158
)
159159

160+
@pytest.mark.timeout(30)
160161
def test_subscribe(self) -> None:
161162
with self.tracer.start_as_current_span("test"):
162163
# Publish a message

tests/requirements-minimal.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
coverage>=5.5
22
pytest>=4.6
3+
pytest-timeout>=2.4.0

0 commit comments

Comments
 (0)