skip to navigation
skip to content

pytest-openfiles 0.2.0

Pytest plugin for detecting inadvertent open file handles

This package provides a plugin for the pytest framework that allows developers to detect whether any file handles or other file-like objects were inadvertently left open at the end of a unit test. It has been moved from the core astropy project since it is of use more generally.

NOTE: This plugin is not supported with Py2.7 on Win32 platforms.


The pytest-openfiles plugin allows for the detection of open I/O resources at the end of unit tests. This is particularly useful for testing code that manipulates file handles or other I/O resources. It allows developers to ensure that this kind of code properly cleans up I/O resources when they are no longer needed.


The pytest-openfiles plugin can be installed using pip:

$ pip install pytest-openfiles

It is also possible to install the latest development version from the source repository:

$ git clone
$ cd pytest-openfiles
$ python ./ install

In either case, the plugin will automatically be registered for use with pytest.


This plugin adds the --open-files option to the pytest command. When running tests with --open-files, if a file is opened during the course of a unit test but that file is not closed before the test finishes, the test will fail.

Development Status

Questions, bug reports, and feature requests can be submitted on github.


This plugin is licensed under a 3-clause BSD style license - see the LICENSE.rst file.

File Type Py Version Uploaded on Size
pytest-openfiles-0.2.0.tar.gz (md5, pgp) Source 2017-12-07 5KB