Skip to main content

🛎 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 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-2.0.0.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

impall-2.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: impall-2.0.0.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for impall-2.0.0.tar.gz
Algorithm Hash digest
SHA256 b0599d6f8aa7645c8a74cf76f6c5f0a61cb134fc6cbbf56c9b3c5230d30f6050
MD5 3a8a810fb5114455c4500e784c9a4ab7
BLAKE2b-256 a2b2df92c0d5af6b0e447cc6d5413df44eb198ee7eccff5b62027beb618a99cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: impall-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for impall-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4f864dc604d863c743389455b5988120e8b844b778576622aa647e283cffb15
MD5 af333cfb4fc00e1868854d3b7a982bbe
BLAKE2b-256 38eef34baf5f0c8601bf0e00ec8ad025ca527d51ad929877e4214d7f5a52fd31

See more details on using hashes here.

Supported by

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