Skip to main content

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


Download files

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

Source Distribution

impall-0.9.8.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

impall-0.9.8-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: impall-0.9.8.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for impall-0.9.8.tar.gz
Algorithm Hash digest
SHA256 c91aac13da19aaad04ccf85e1b6d8155a0c35d56df3c9e073deaa96cd42a1a44
MD5 a203aa8b91b74f0f9f2a0a66271b53ca
BLAKE2b-256 624f1831b2353af4afc5504bcd8ea8a051bdd3b4ffea0250deceac04c139fc23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: impall-0.9.8-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for impall-0.9.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7b399f0eb5cb2e432861fc918d65f6d99d66281d6805f7028f2322c22c6a6a78
MD5 92cb1fd01c95bcd283836a2c2cb8104c
BLAKE2b-256 5513d8c2728cb9b72e947ce9ceaf84ea60f0e161100944a7640a0ef1e6cb3436

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