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

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.1.2.tar.gz (4.4 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.1.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: borderline-0.1.2.tar.gz
  • Upload date:
  • Size: 4.4 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.1.2.tar.gz
Algorithm Hash digest
SHA256 9932a95112cf7920adfa20b20efd7f1e0af2b3dea9cee779dfc1d0691a202044
MD5 27edd2cacd475cef9c0f4d11ca04868c
BLAKE2b-256 3563e6c28ee5173652e061b3e38854008ccb463f55d607026884ae94748ccdb6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: borderline-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05d141b9f1f75916dd3886482c9dcb2336bb20c85c70227df3e6e81cc1de6453
MD5 93cc28ef2ea3e5a1e477ee3b128c9983
BLAKE2b-256 b24f460fe3da6cd722d212a0bb5bc16dfe978d296e7f0408f5ec75979f59adcf

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