Try to import all modules below a given root
Project description
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.
impall 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 impall
Install it with pip install impall, and use it by adding this tiny file (raw) anywhere in a project - it looks like this:
import impall
class ImpAllTest(impall.ImpAllTest):
pass
and most of the time that’s all you need.
Overriding properties
ImpAllTest 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 impall
class ImpAllTest(impall.ImpAllTest):
WARNINGS_ACTION = 'error'
To temporarily override a test property, set an environment variable before runnning the test, like this:
$ _IMPALL_WARNINGS_ACTION=error pytest
Using impall.py as a standalone program
The file impall.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:
$ impall.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:
$ impall.py --catch_exceptions --all_directories --exclude=foo/bar
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file impall-0.10.0.tar.gz
.
File metadata
- Download URL: impall-0.10.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/18.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d76abc5cccc830863e7f9c04520a4a6666aac650cb07889530ff3a0355c1151 |
|
MD5 | be9ca62699b269ed763d1da39f9c1b5c |
|
BLAKE2b-256 | 6841ff7f4d161c46ff789ea98cd95b099e16bd62fbd81bda44e2fcbb929a609b |
File details
Details for the file impall-0.10.0-py3-none-any.whl
.
File metadata
- Download URL: impall-0.10.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/18.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea7ed5032698cdfb12800884bbf12d6d24796aa7108f91bf6450c47ea1778d95 |
|
MD5 | 26ed27070753792cb95a9ab01abe7472 |
|
BLAKE2b-256 | 5b3df931e9468521150d7f30991c9d29bb82de0a3b1dd37c83410ba8414e40d6 |