Skip to main content

pytest-filecov

Overview

This is a pytest plugin to monitor file accesses while tests are running, then output a report listing files along with whether or not they were accessed:

$ py.test --filecov tests
============================= test session starts ==============================
platform linux -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
filecov: tests
rootdir: /home/rohan/src/pytest-filecov
plugins: cov-2.12.1, filecov-0.1.0
collected 3 items

tests/test_plugin.py ...                                                 [100%]

============================ pytest-filecov report =============================
Filename                 Covered?
--------                 --------
tests/__init__.py        0
tests/fakecmd.py         1
tests/test_plugin.py     1
tests/some-file          1
tests/other-file         0
============================== 3 passed in 0.13s ===============================

Usage

Prerequisites:

  • Linux
  • inotifywait (try installing inotify-tools package)

Install the plugin:

pip install pytest-filecov

When running your test suite, add --filecov <path> specifying the directory tree(s) for which you'd like a report:

py.test --filecov somedir

Why?

This plugin targets the following scenario:

  • You've got a large, complex test suite.
  • You've got some tests relying on external data stored in files.
  • After some refactors, you expect some of the test data files are now unused and you'd like to clean them up, but you have no reliable way to determine what is or is not used.

Just as pytest-cov can help you seek and destroy dead Python code after refactors, pytest-filecov can do the same for dead/unused data files.

Caveats and missing features

This plugin is rudimentary, with many missing features.

  • The format of the reporter is not configurable.
  • The list of files included in the report comes from git ls-files and this is not configurable.
  • .py files may commonly be listed as uncovered for various reasons (e.g. .pyc files were used; or files were imported before monitoring began)

Contributions to improve any of the above are welcome.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Metadata

Release files for pytest-filecov 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-filecov 0.1.1
File Size Uploaded
pytest-filecov-0.1.1.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-filecov 0.1.1
File Interpreter ABI Platform
pytest_filecov-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / pytest-filecov-0.1.1.tar.gz

Download URL pytest-filecov-0.1.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
189e916ef7a11206e8f870edff3193ce2a214832a971144e10a890879baac96e
BLAKE2b-256 checksum
How to use checksums
66757e5b320067baf2a77a473c145dc8731d08d4140c775003aeb11ca688c682
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

Release files / pytest_filecov-0.1.1-py3-none-any.whl

Download URL pytest_filecov-0.1.1-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fd55eb2d6af156d2b9c077d5f7138d65927dd1dcdb886ae3d7e71e2f4926d83
BLAKE2b-256 checksum
How to use checksums
856dcdb6d05457dfbc7661d47f5c4fc25d737774a4fb0dcecc6c0c13c00dc266
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

Release history Release notifications | RSS feed

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page