Skip to main content

🛎 Test-import all modules below a given root 🛎

Project description

🏁 impall: automatically import all Python modules for testing 🏁

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.py --warnings_action=error
$ impall.py -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 not foo.foo
  • matches bar.foo but not bar or bar.foo.bar
  • matches baz.foo as well as baz.foo.bar but not baz

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

impall-1.2.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

impall-1.2.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file impall-1.2.0.tar.gz.

File metadata

  • Download URL: impall-1.2.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.9 Darwin/21.6.0

File hashes

Hashes for impall-1.2.0.tar.gz
Algorithm Hash digest
SHA256 25bda4cbe7ddc3ff93b129a60f51622b16ac516c9327b5a302bb805c9b826a35
MD5 d2c5114c9f079ec28291865134f7183d
BLAKE2b-256 7a9debee6b463df8ec493e178aca5a755f292886459195a1aef883cae4f616ef

See more details on using hashes here.

File details

Details for the file impall-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: impall-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.9 Darwin/21.6.0

File hashes

Hashes for impall-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f75e68526de2c84ce88a3a59ad7aaa42f3b7525a82c1f376f53e46b9b25410cd
MD5 450e7e3111c386667478538cdc23ce4e
BLAKE2b-256 0ddeaf87371a89dccf1e779442f96704b40b1c8113a22af63ef13f764e4c16ea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page