🛎 Test-import all modules 🛎
Project description
🛎 Test-import all modules 🛎
Individually and separately imports each Python module or file in a project and reports warnings or failures at the end.
Running impall as a unit test
Just inherit from the base class and it will automatically find and import each file, like this.
import impall
class ImpAllTest(impall.ImpAllTest):
pass
(You can copy this file into your project if you like.)
Tests are customized by overriding one of these following properties in the derived class.
CLEAR_SYS_MODULES, EXCLUDE, FAILING, INCLUDE, MODULES, PATHS,
RAISE_EXCEPTIONS, and WARNINGS_ACTION.
For example, to turn warnings into errors, set the property WARNINGS_ACTION in the derived class definition, like this.
class ImpAllTest(impall.ImpAllTest):
WARNINGS_ACTION = 'error'
Running impall as a command-line utility
$ impall --warnings_action=error
$ impall -w error
The properties INCLUDE, EXCLUDE, and PROJECT_PATH can be lists of strings, or a string separated with colons like 'foo.mod1:foo.mod2'
INCLUDE and EXCLUDE match modules, and also allow * as a wildcard. A single * matches any module segment, and a double ** matches any remaining segments. For example,
INCLUDE = 'foo', 'bar.*', 'baz.**'
- matches
foo
but notfoo.foo
- matches
bar.foo
but notbar
orbar.foo.bar
- matches
baz.foo
as well asbaz.foo.bar
but notbaz
A note on side-effects
to reduce side-effects, sys.modules
is restored to its original
condition after each import if CLEAR_SYS_MODULES is true, but there might be
other side-effects from loading some specific module.
Use the EXCLUDE property to exclude modules with undesirable side effects. In general, it is probably a bad idea to have significant side-effects just from loading a module.
API Documentation
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-1.5.3.tar.gz
.
File metadata
- Download URL: impall-1.5.3.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.11 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58d420ac9070db04a15ea39d75dddf2ab8cd3fd340a1d23bf9a4187184dab9ee |
|
MD5 | 3f99f8e5b92772cb574ebbe2f261af77 |
|
BLAKE2b-256 | bcd273d301539dfb398c3ccba94e2ff3812bfb1b87f62be1024173ecc6e12b01 |
File details
Details for the file impall-1.5.3-py3-none-any.whl
.
File metadata
- Download URL: impall-1.5.3-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.11 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3c8b1e7b13ba547f9073309acd6388242c7cace49b27f9f05caff04ad02baf0 |
|
MD5 | 99edb881c3ad467f38f254405caf1f3f |
|
BLAKE2b-256 | 968f5feffe82d861c57b89a2482019883a4fb982158f3cd56c75ce085c2fe743 |