diff --git a/doc/en/explanation/fixtures.rst b/doc/en/explanation/fixtures.rst index 3bda29d57..27677ddbc 100644 --- a/doc/en/explanation/fixtures.rst +++ b/doc/en/explanation/fixtures.rst @@ -156,3 +156,20 @@ Another good approach is by adding the data files in the ``tests`` folder. There are also community plugins available to help to manage this aspect of testing, e.g. `pytest-datadir `__ and `pytest-datafiles `__. + +.. _fixtures-signal-cleanup: + +A note about fixture cleanup +---------------------------- + +pytest does not do any special processing for :data:`SIGTERM ` and +:data:`SIGQUIT ` signals (:data:`SIGINT ` is handled naturally +by the Python runtime via :class:`KeyboardInterrupt`), so fixtures that manage external resources which are important +to be cleared when the Python process is terminated (by those signals) might leak resources. + +The reason pytest does not handle those signals to perform fixture cleanup is that signal handlers are global, +and changing them might interfere with the code under execution. + +If fixtures in your suite need special care regarding termination in those scenarios, +see `this comment `__ in the issue +tracker for a possible workaround.