Skip to content

Commit c4557c3

Browse files
authored
Merge pull request #9150 from nicoddemus/issue-9141-fixture-docs
2 parents 8a58b0c + ac3614b commit c4557c3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/en/explanation/fixtures.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,20 @@ Another good approach is by adding the data files in the ``tests`` folder.
156156
There are also community plugins available to help to manage this aspect of
157157
testing, e.g. `pytest-datadir <https://pypi.org/project/pytest-datadir/>`__
158158
and `pytest-datafiles <https://pypi.org/project/pytest-datafiles/>`__.
159+
160+
.. _fixtures-signal-cleanup:
161+
162+
A note about fixture cleanup
163+
----------------------------
164+
165+
pytest does not do any special processing for :data:`SIGTERM <signal.SIGTERM>` and
166+
:data:`SIGQUIT <signal.SIGQUIT>` signals (:data:`SIGINT <signal.SIGINT>` is handled naturally
167+
by the Python runtime via :class:`KeyboardInterrupt`), so fixtures that manage external resources which are important
168+
to be cleared when the Python process is terminated (by those signals) might leak resources.
169+
170+
The reason pytest does not handle those signals to perform fixture cleanup is that signal handlers are global,
171+
and changing them might interfere with the code under execution.
172+
173+
If fixtures in your suite need special care regarding termination in those scenarios,
174+
see `this comment <https://github.com/pytest-dev/pytest/issues/5243#issuecomment-491522595>`__ in the issue
175+
tracker for a possible workaround.

0 commit comments

Comments
 (0)