././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1587051282.899729 pytest-openfiles-0.5.0/0000775000175000017500000000000000000000000014451 5ustar00tomtom00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051136.0 pytest-openfiles-0.5.0/.gitignore0000664000175000017500000000116300000000000016442 0ustar00tomtom00000000000000# Compiled files *.py[cod] *.a *.o *.so *.pyd __pycache__ # Ignore .c files by default to avoid including generated code. If you want to # add a non-generated .c extension, use `git add -f filename.c`. *.c # Other generated files MANIFEST # Sphinx _build _generated docs/api docs/generated # Packages/installer info *.egg *.egg-info dist build eggs .eggs parts bin var sdist develop-eggs .installed.cfg distribute-*.tar.gz # Other .cache .tox .*.swp .*.swo *~ .project .pydevproject .settings .coverage cover htmlcov # Generated by Pytest v .pytest_cache # Mac OSX .DS_Store # PyCharm .idea pytest_openfiles/version.py ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051136.0 pytest-openfiles-0.5.0/.travis.yml0000664000175000017500000000330100000000000016557 0ustar00tomtom00000000000000# We set the language to c because python isn't supported on the MacOS X nodes # on Travis. However, the language ends up being irrelevant anyway, since we # install Python ourselves using conda. language: c os: - linux # Use Travis' container-based architecture sudo: false env: global: # The following versions are the 'default' for tests, unless # overidden underneath. They are defined here in order to save having # to repeat them for all configurations. - TOXENV='test' - TOXARGS='-v' - TOXPOSARGS='' matrix: include: - language: python python: 3.6 name: Python 3.6 and pytest 4.6 (Linux) env: TOXENV=py36-test-pytest46 - os: windows name: Python 3.6 and pytest 5.0 (Windows) env: PYTHON_VERSION=3.6 TOXENV=py36-test-pytest50 - os: osx name: Python 3.7 and pytest 5.1 (MacOS X) env: PYTHON_VERSION=3.7 TOXENV=py37-test-pytest51 - language: python python: 3.7 name: Python 3.7 and pytest 5.2 (Linux) env: TOXENV=py37-test-pytest52 - os: windows name: Python 3.8 and pytest 5.3 (Windows) env: PYTHON_VERSION=3.8 TOXENV=py38-test-pytest53 - os: osx name: Python 3.8 and pytest dev (MacOS X) env: PYTHON_VERSION=3.8 TOXENV=py38-test-pytestdev install: - if [[ $TRAVIS_OS_NAME == osx || $TRAVIS_OS_NAME == windows ]]; then git clone git://github.com/astropy/ci-helpers.git; source ci-helpers/travis/setup_conda.sh; fi script: - pip install tox - tox $TOXARGS -- $TOXPOSARGS ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051206.0 pytest-openfiles-0.5.0/CHANGES.rst0000664000175000017500000000152500000000000016256 0ustar00tomtom000000000000000.5.0 (2020-04-16) ================== - Updated package infrastructure. [#29] - Force garbage collection before checking for open files. [#30] 0.4.0 (2019-07-20) ================== - Added the ability to use ``*`` and ``?`` wildcards in ``open_files_ignore``. [#22] - Fixed compatibility with pytest 4.2. [#20] 0.3.2 (2019-01-07) ================== - Replace deprecated method to allow for compatibility with ``pytest-4.1`` and later. [#19] 0.3.1 (2018-11-26) ================== - Fix a minor packaging issue. [#13] 0.3.0 (2018-04-20) ================== - Add decorator to skip detection of open files for particular tests. [#10] - Fix packaging error: do not include tests in package distribution. [#11] 0.2 (2017-12-07) ================ - Remove test dependency on astropy. [#4] 0.1 (2017-10-09) ================ - Alpha release. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1579105228.0 pytest-openfiles-0.5.0/LICENSE.rst0000644000175000017500000000273000000000000016265 0ustar00tomtom00000000000000Copyright (c) 2011-2017, Astropy Developers All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Astropy Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051137.0 pytest-openfiles-0.5.0/MANIFEST.in0000664000175000017500000000023100000000000016203 0ustar00tomtom00000000000000include LICENSE.rst include README.rst include CHANGES.rst include setup.cfg include pyproject.toml recursive-include tests * global-exclude *.pyc *.o ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1587051282.899729 pytest-openfiles-0.5.0/PKG-INFO0000664000175000017500000001161600000000000015553 0ustar00tomtom00000000000000Metadata-Version: 1.2 Name: pytest-openfiles Version: 0.5.0 Summary: Pytest plugin for detecting inadvertent open file handles Home-page: https://github.com/astropy/pytest-openfiles Author: The Astropy Developers Author-email: astropy.team@gmail.com License: BSD Description: ================ pytest-openfiles ================ 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. .. _pytest: https://pytest.org/en/latest/ .. _astropy: https://astropy.org/en/latest/ Motivation ---------- 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. Installation ------------ 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 https://github.com/astropy/pytest-openfiles $ cd pytest-openfiles $ python ./setup.py install In either case, the plugin will automatically be registered for use with ``pytest``. Usage ----- 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. In some cases certain files are expected to remain open between tests. In order to prevent these files from causing tests to fail, they can be ignored using the configuration file variable ``open_files_ignore``. This variable is added to the ``[tool:pytest]`` section of a package's top-level ``setup.cfg`` file. Files can be ignored using a fully specified filename:: [tool:pytest] open_files_ignore = "/home/user/monty/output.log" It is also possible to ignore files with a particular name regardless of where they reside in the file system:: [tool:pytest] open_files_ignore = "output.log" In this example, all files named ``output.log`` will be ignored if they are found to remain open after a test completes. Paths and filenames can include ``*`` and ``?`` as wildcards:: [tool:pytest] open_files_ignore = "*.ttf" It is also possible to ignore open files for particular test cases by decorating them with the ``openfiles_ignore`` decorator: .. code:: import pytest @pytest.mark.openfiles_ignore def test_open_file_and_ignore(): """We want to ignore this test when checking for open file handles.""" The test function will not be skipped, but any files that are left open by the test will be ignored by this plugin. Development Status ------------------ .. image:: https://travis-ci.org/astropy/pytest-openfile.svg :target: https://travis-ci.org/astropy/pytest-openfiles :alt: Travis CI Status Questions, bug reports, and feature requests can be submitted on `github`_. .. _github: https://github.com/astropy/pytest-openfiles License ------- This plugin is licensed under a 3-clause BSD style license - see the ``LICENSE.rst`` file. Keywords: detect,open,file,handle,psutil,pytest,py.test Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Framework :: Pytest Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Utilities Requires-Python: >=3.6 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051137.0 pytest-openfiles-0.5.0/README.rst0000664000175000017500000000613100000000000016141 0ustar00tomtom00000000000000================ pytest-openfiles ================ 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. .. _pytest: https://pytest.org/en/latest/ .. _astropy: https://astropy.org/en/latest/ Motivation ---------- 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. Installation ------------ 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 https://github.com/astropy/pytest-openfiles $ cd pytest-openfiles $ python ./setup.py install In either case, the plugin will automatically be registered for use with ``pytest``. Usage ----- 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. In some cases certain files are expected to remain open between tests. In order to prevent these files from causing tests to fail, they can be ignored using the configuration file variable ``open_files_ignore``. This variable is added to the ``[tool:pytest]`` section of a package's top-level ``setup.cfg`` file. Files can be ignored using a fully specified filename:: [tool:pytest] open_files_ignore = "/home/user/monty/output.log" It is also possible to ignore files with a particular name regardless of where they reside in the file system:: [tool:pytest] open_files_ignore = "output.log" In this example, all files named ``output.log`` will be ignored if they are found to remain open after a test completes. Paths and filenames can include ``*`` and ``?`` as wildcards:: [tool:pytest] open_files_ignore = "*.ttf" It is also possible to ignore open files for particular test cases by decorating them with the ``openfiles_ignore`` decorator: .. code:: import pytest @pytest.mark.openfiles_ignore def test_open_file_and_ignore(): """We want to ignore this test when checking for open file handles.""" The test function will not be skipped, but any files that are left open by the test will be ignored by this plugin. Development Status ------------------ .. image:: https://travis-ci.org/astropy/pytest-openfile.svg :target: https://travis-ci.org/astropy/pytest-openfiles :alt: Travis CI Status Questions, bug reports, and feature requests can be submitted on `github`_. .. _github: https://github.com/astropy/pytest-openfiles License ------- This plugin is licensed under a 3-clause BSD style license - see the ``LICENSE.rst`` file. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051137.0 pytest-openfiles-0.5.0/pyproject.toml0000664000175000017500000000020400000000000017361 0ustar00tomtom00000000000000[build-system] requires = ["setuptools", "setuptools_scm", "wheel"] build-backend = 'setuptools.build_meta' ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1587051282.899729 pytest-openfiles-0.5.0/pytest_openfiles/0000775000175000017500000000000000000000000020045 5ustar00tomtom00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051137.0 pytest-openfiles-0.5.0/pytest_openfiles/__init__.py0000664000175000017500000000030300000000000022152 0ustar00tomtom00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This package contains pytest plugins that are used by the astropy test suite. """ from .version import version as __version__ ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051137.0 pytest-openfiles-0.5.0/pytest_openfiles/plugin.py0000664000175000017500000001054500000000000021722 0ustar00tomtom00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This plugin provides support for testing whether file-like objects are properly closed. """ import os import gc import fnmatch from distutils.version import LooseVersion import pytest try: import importlib.machinery as importlib_machinery except ImportError: import imp importlib_machinery = None _pytest_36 = LooseVersion(pytest.__version__) >= LooseVersion("3.6") def pytest_addoption(parser): parser.addoption("--open-files", action="store_true", help="fail if any test leaves files open") parser.addini("open_files_ignore", "when used with the --open-files option, allows " "specifying names of files that may be ignored when " "left open between tests--files in this list are matched " "may be specified by their base name (ignoring their full " "path) or by absolute path", type="args", default=()) def pytest_configure(config): config.getini('markers').append( 'openfiles_ignore: Indicate that open files should be ignored for this test') # Open file detection. # # This works by calling out to psutil to get the list of open files # held by the process both before and after the test. If something is # still open after the test that wasn't open before the test, an # AssertionError is raised. # # This is not thread-safe. We're not currently running our tests # multi-threaded, but that is worth noting. def _get_open_file_list(): import psutil files = [] p = psutil.Process() if importlib_machinery is not None: suffixes = tuple(importlib_machinery.all_suffixes()) else: suffixes = tuple(info[0] for info in imp.get_suffixes()) files = [x.path for x in p.open_files() if not x.path.endswith(suffixes)] return set(files) def pytest_runtest_setup(item): # Store a list of the currently opened files so we can compare # against them when the test is done. if item.config.getvalue('open_files'): # Retain backwards compatibility with earlier versions of pytest if _pytest_36: ignore = item.get_closest_marker('openfiles_ignore') else: ignore = item.get_marker('openfiles_ignore') if not ignore: item.open_files = _get_open_file_list() def pytest_runtest_teardown(item, nextitem): # a "skipped" test will not have been called with # pytest_runtest_setup, so therefore won't have an # "open_files" member if (not item.config.getvalue('open_files') or not hasattr(item, 'open_files')): return start_open_files = item.open_files del item.open_files # We now force garbage collection - we need to do this because e.g. in cases # where a memory mapped array was opened in the test and then goes out of # scope at the end of the test, the original file may still be open but # can be properly closed by forcing gc.collect(). This was found to be # needed for astropy.io.fits under certain circumstances. gc.collect() open_files = _get_open_file_list() # This works in tandem with the test_open_file_detection test to # ensure that it creates one extra open file. if item.name == 'test_open_file_detection': assert len(start_open_files) + 1 == len(open_files) return not_closed = set() open_files_ignore = item.config.getini('open_files_ignore') for filename in open_files: ignore = False for ignored in open_files_ignore: # Note that we use fnmatch rather than re for simplicity since # we are dealing with file paths - fnmatch works with the standard # * and ? wildcards in paths. if not os.path.isabs(ignored): # Since the path is not absolute, we convert it to # */ to make sure it matches absolute paths. ignored = os.path.join('*', ignored) if fnmatch.fnmatch(filename, ignored): ignore = True break if ignore: continue if filename not in start_open_files: not_closed.add(filename) if len(not_closed): msg = ['File(s) not closed:'] for name in not_closed: msg.append(' {0}'.format(name)) raise AssertionError('\n'.join(msg)) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051282.0 pytest-openfiles-0.5.0/pytest_openfiles/version.py0000664000175000017500000000016400000000000022105 0ustar00tomtom00000000000000# coding: utf-8 # file generated by setuptools_scm # don't change, don't track in version control version = '0.5.0' ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1587051282.899729 pytest-openfiles-0.5.0/pytest_openfiles.egg-info/0000775000175000017500000000000000000000000021537 5ustar00tomtom00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051282.0 pytest-openfiles-0.5.0/pytest_openfiles.egg-info/PKG-INFO0000664000175000017500000001161600000000000022641 0ustar00tomtom00000000000000Metadata-Version: 1.2 Name: pytest-openfiles Version: 0.5.0 Summary: Pytest plugin for detecting inadvertent open file handles Home-page: https://github.com/astropy/pytest-openfiles Author: The Astropy Developers Author-email: astropy.team@gmail.com License: BSD Description: ================ pytest-openfiles ================ 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. .. _pytest: https://pytest.org/en/latest/ .. _astropy: https://astropy.org/en/latest/ Motivation ---------- 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. Installation ------------ 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 https://github.com/astropy/pytest-openfiles $ cd pytest-openfiles $ python ./setup.py install In either case, the plugin will automatically be registered for use with ``pytest``. Usage ----- 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. In some cases certain files are expected to remain open between tests. In order to prevent these files from causing tests to fail, they can be ignored using the configuration file variable ``open_files_ignore``. This variable is added to the ``[tool:pytest]`` section of a package's top-level ``setup.cfg`` file. Files can be ignored using a fully specified filename:: [tool:pytest] open_files_ignore = "/home/user/monty/output.log" It is also possible to ignore files with a particular name regardless of where they reside in the file system:: [tool:pytest] open_files_ignore = "output.log" In this example, all files named ``output.log`` will be ignored if they are found to remain open after a test completes. Paths and filenames can include ``*`` and ``?`` as wildcards:: [tool:pytest] open_files_ignore = "*.ttf" It is also possible to ignore open files for particular test cases by decorating them with the ``openfiles_ignore`` decorator: .. code:: import pytest @pytest.mark.openfiles_ignore def test_open_file_and_ignore(): """We want to ignore this test when checking for open file handles.""" The test function will not be skipped, but any files that are left open by the test will be ignored by this plugin. Development Status ------------------ .. image:: https://travis-ci.org/astropy/pytest-openfile.svg :target: https://travis-ci.org/astropy/pytest-openfiles :alt: Travis CI Status Questions, bug reports, and feature requests can be submitted on `github`_. .. _github: https://github.com/astropy/pytest-openfiles License ------- This plugin is licensed under a 3-clause BSD style license - see the ``LICENSE.rst`` file. Keywords: detect,open,file,handle,psutil,pytest,py.test Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Framework :: Pytest Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Utilities Requires-Python: >=3.6 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051282.0 pytest-openfiles-0.5.0/pytest_openfiles.egg-info/SOURCES.txt0000664000175000017500000000106300000000000023423 0ustar00tomtom00000000000000.gitignore .travis.yml CHANGES.rst LICENSE.rst MANIFEST.in README.rst pyproject.toml setup.cfg setup.py tox.ini pytest_openfiles/__init__.py pytest_openfiles/plugin.py pytest_openfiles/version.py pytest_openfiles.egg-info/PKG-INFO pytest_openfiles.egg-info/SOURCES.txt pytest_openfiles.egg-info/dependency_links.txt pytest_openfiles.egg-info/entry_points.txt pytest_openfiles.egg-info/not-zip-safe pytest_openfiles.egg-info/requires.txt pytest_openfiles.egg-info/top_level.txt tests/__init__.py tests/test_open_file_detection.py tests/data/open_file_detection.txt././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051282.0 pytest-openfiles-0.5.0/pytest_openfiles.egg-info/dependency_links.txt0000664000175000017500000000000100000000000025605 0ustar00tomtom00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051282.0 pytest-openfiles-0.5.0/pytest_openfiles.egg-info/entry_points.txt0000664000175000017500000000006700000000000025040 0ustar00tomtom00000000000000[pytest11] pytest_openfiles = pytest_openfiles.plugin ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051282.0 pytest-openfiles-0.5.0/pytest_openfiles.egg-info/not-zip-safe0000664000175000017500000000000100000000000023765 0ustar00tomtom00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051282.0 pytest-openfiles-0.5.0/pytest_openfiles.egg-info/requires.txt0000664000175000017500000000002300000000000024132 0ustar00tomtom00000000000000psutil pytest>=4.6 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051282.0 pytest-openfiles-0.5.0/pytest_openfiles.egg-info/top_level.txt0000664000175000017500000000002100000000000024262 0ustar00tomtom00000000000000pytest_openfiles ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1587051282.899729 pytest-openfiles-0.5.0/setup.cfg0000664000175000017500000000231400000000000016272 0ustar00tomtom00000000000000[metadata] name = pytest-openfiles url = https://github.com/astropy/pytest-openfiles author = The Astropy Developers author_email = astropy.team@gmail.com classifiers = Development Status :: 3 - Alpha Framework :: Pytest Intended Audience :: Developers License :: OSI Approved :: BSD License Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: Implementation :: CPython Topic :: Software Development :: Testing Topic :: Utilities license = BSD description = Pytest plugin for detecting inadvertent open file handles long_description = file: README.rst keywords = detect, open, file, handle, psutil, pytest, py.test [options] zip_safe = False packages = find: python_requires = >=3.6 setup_requires = setuptools_scm install_requires = pytest>=4.6 psutil [options.entry_points] pytest11 = pytest_openfiles = pytest_openfiles.plugin [options.packages.find] exclude = tests [tool:pytest] minversion = 4.6 testpaths = tests [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051137.0 pytest-openfiles-0.5.0/setup.py0000775000175000017500000000101600000000000016164 0ustar00tomtom00000000000000#!/usr/bin/env python import os import sys import setuptools from distutils.version import LooseVersion from setuptools import setup # Setuptools 30.3.0 or later is needed for setup.cfg options to be used if LooseVersion(setuptools.__version__) < LooseVersion('30.3.0'): sys.stderr.write("ERROR: sphinx-automodapi requires setuptools 30.3.0 or " "later (found {0})".format(setuptools.__version__)) sys.exit(1) setup(use_scm_version={'write_to': os.path.join('pytest_openfiles', 'version.py')}) ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1587051282.899729 pytest-openfiles-0.5.0/tests/0000775000175000017500000000000000000000000015613 5ustar00tomtom00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1579105228.0 pytest-openfiles-0.5.0/tests/__init__.py0000644000175000017500000000010000000000000017711 0ustar00tomtom00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1587051282.899729 pytest-openfiles-0.5.0/tests/data/0000775000175000017500000000000000000000000016524 5ustar00tomtom00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1579105228.0 pytest-openfiles-0.5.0/tests/data/open_file_detection.txt0000644000175000017500000000001100000000000023251 0ustar00tomtom00000000000000CONTENTS ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587045833.0 pytest-openfiles-0.5.0/tests/test_open_file_detection.py0000664000175000017500000000073700000000000023231 0ustar00tomtom00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst import os import pytest PKG_DATA_DIR = os.path.dirname(__file__) fd = None def test_open_file_detection(): global fd fd = open(os.path.join(PKG_DATA_DIR, 'data/open_file_detection.txt')) @pytest.mark.openfiles_ignore def test_skip_open_file_detection(): global fd fd = open(os.path.join(PKG_DATA_DIR, 'data/open_file_detection.txt')) def teardown(): if fd is not None: fd.close() ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1587051137.0 pytest-openfiles-0.5.0/tox.ini0000664000175000017500000000125000000000000015762 0ustar00tomtom00000000000000[tox] envlist = py{36,37,38}-test{,-devdeps} codestyle requires = setuptools >= 30.3.0 pip >= 19.3.1 isolated_build = true [testenv] changedir = .tmp/{envname} description = run tests deps = pytest46: pytest==4.6.* pytest50: pytest==5.0.* pytest51: pytest==5.1.* pytest52: pytest==5.2.* pytest53: pytest==5.3.* pytestdev: git+https://github.com/pytest-dev/pytest#egg=pytest commands = pip freeze pytest {toxinidir}/tests {posargs} pytest --open-files {toxinidir}/tests {posargs} [testenv:codestyle] skip_install = true description = check code style, e.g. with flake8 deps = flake8 commands = flake8 pytest_openfiles --count