pytest-dev / pytest-timeout

MIT License
213 stars 64 forks source link

Is there a way to exclude test db setup from the timeout? #136

Closed aqeelat closed 2 years ago

aqeelat commented 2 years ago
platform darwin -- Python 3.9.13, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /Users/aqeelat/lab/venv/bin/python
cachedir: .pytest_cache
django: settings: project.settings (from env)
rootdir: /Users/aqeelat/project, configfile: pyproject.toml
plugins: xdist-2.5.0, forked-1.4.0, timeout-2.1.0, celery-4.4.7, django-4.5.2, cov-3.0.0
timeout: 300.0s
timeout method: signal
timeout func_only: False

So, my issue is: The database migration takes about 2.5 minutes. This means that I have to set my timeout to migration time + timeout. This timeout will apply to all tests. Is there a way to exclude the migrations from the timeout?

flub commented 2 years ago

It's not so bad to set a timeout large enough for the migration time + test and use that same large timeout for all tests, it is in fact recommended usage. If you really disagree you can try using the timeout_func_only setting: https://github.com/pytest-dev/pytest-timeout/blob/7d4c413a6344edd8340628354419a324e68c6cb7/pytest_timeout.py#L38-L42