import_all: Automatically import everything
A three-line unit test in your project automatically imports every Python file and module in it, optionally testing for warnings.
Why?
Not every file is covered by unit tests; and unit tests won’t report any new warnings that occur.
import_all is a single-file library with a unit test that automatically imports every Python file and module in your project.
I drop include_all into each new project. It takes seconds, it inevitably catches lots of dumb problems early, and it requires no maintenance.
How to use import_all
Install it with pip install import_all, and use it by adding this tiny file (raw) anywhere in a project - it looks like this:
import import_all
class ImportAllTest(import_all.ImportAllTest):
pass
and most of the time that’s all you need.
Overriding properties
ImportAllTest has eight properties that can be overridden.
ALL_SUBDIRECTORIES: Whether to search all subdirectories
CATCH_EXCEPTIONS: Catch all exceptions and report at the end
EXCLUDE: Which modules to exclude
EXPECTED_TO_FAIL: Which modules are expected to fail
INCLUDE: Which modules to exclude
PROJECT_PATHS: Roots for searching subdirectories
SKIP_PREFIXES: Skip subdirectories that start with these prefixes
WARNINGS_ACTION: What to do on warnings
Full documentation for each property is here.
To permanently override a test property, set it in the derived class, like this:
import import_all
class ImportAllTest(import_all.ImportAllTest):
WARNINGS_ACTION = 'error'
To temporarily override a test property, set an environment variable before runnning the test, like this:
$ _IMPORT_ALL_WARNINGS_ACTION=error pytest
Using import_all.py as a standalone program
The file import_all.py is executable and is installed in the path by pip. You can use it on projects that you are evaluating or debugging like this:
$ import_all.py [directory ..directory]
where if no directory is specified it uses the current directory.
You can use environment variables to set properties as above and for convenience there are also command line flags for each property, so you can write:
$ import_all.py --catch_exceptions --all_directories --exclude=foo/bar
Metadata
Release files for import_all 0.9.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| import_all-0.9.5.tar.gz | 6.6 kB | Without provenance | Details for import_all-0.9.5.tar.gz |
Release files / import_all-0.9.5.tar.gz
| Download URL | import_all-0.9.5.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77ed30b6537ebf59fb3ae3dd4706c9a257670ef3fb05042b482ec5058bd3b868
|
|
BLAKE2b-256 checksum How to use checksums |
1d4feed24061302cd7671d37a8ad7501389b26646a65d69002dc0f2e080d6c7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.5
|
Security for import_all 0.9.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.