Skip to main content

Tests that new imports within a module respect the public API boundary.

Project description

Borderline

Stop letting modules reach into other modules.


python-package PyPI version fury.io

This library provides one thing and one thing only: a test class called TestModuleImports.

To use the test, subclass it in the test suite of the module you want to isolate and define that module's borderlines. The test will fail if a module is not respecting those borderlines.

For example, a module called report_builder could have the following definition:

class TestReportBuilder(TestModuleImports):
    module = "reporting.report_builder"
    
    # The public API of the module.
    # External modules should only import from here.
    public_modules = (
        "reporting.report_builder.api",
    )
    # Modules that are considered outside of `module` and should not be imported
    # by `module` unless they are a legitimate dependency.
    external_modules = (
        "reporting",
    )
    # Modules outside of `module` that ARE legitimate dependencies.
    external_dependencies = (
        "reporting.review.api",
        "reporting.common",
    )

    # Directory to store imports that are currently allowed.
    # This is useful when you are trying to isolate an existing module
    # that is not respecting its borderlines.
    grandfather_filedir = Path(
        "reporting/report_builder/tests/data/borderline", parents=True, exist_ok=True
    )

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

borderline-0.2.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

borderline-0.2.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file borderline-0.2.0.tar.gz.

File metadata

  • Download URL: borderline-0.2.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.11 Darwin/20.6.0

File hashes

Hashes for borderline-0.2.0.tar.gz
Algorithm Hash digest
SHA256 754f24c6dbae845f1bfdd04a38360fef222a479bf3d14c123de071f6a49a39c3
MD5 eeff5cc9f3ea5f9031ef137c9e4bf634
BLAKE2b-256 8cb5099cf1f716b505246e3ae3cf808a29469b9c443516bb28efe49cdff78b2a

See more details on using hashes here.

File details

Details for the file borderline-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: borderline-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.11 Darwin/20.6.0

File hashes

Hashes for borderline-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6975e2cf2899dc22dc8b13f6682b21ff8ff45d710c59cb99fd87224814a8659e
MD5 3aac0a9de9e4951f283b85ebfa2d6926
BLAKE2b-256 8d639bd23887055c29728f91167307a1d9711525461b698b251ab85e1fd3ec92

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