Tests that new imports within a module respect the public API boundary.
Project description
Borderline
Stop letting modules reach into other modules.
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(ModuleImports):
module = "reporting.report_builder"
# The public API of the module.
# External modules should only import from here.
public_submodules = (
"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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file borderline-0.3.0.tar.gz.
File metadata
- Download URL: borderline-0.3.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.8.11 Darwin/20.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
530ed2501536ff3b58c5d82f7b7ffe06ae94ce64e5c293a5b0407c8df0386e5e
|
|
| MD5 |
e8a87e8b51009625bb61baaf02007720
|
|
| BLAKE2b-256 |
c01a31c87874cfc13c4ad569e01dba2523b778bc4cc9f54a90aaa98ff1184a4e
|
File details
Details for the file borderline-0.3.0-py3-none-any.whl.
File metadata
- Download URL: borderline-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a8633b3e3456041b09063bbff0b4433eaaa5e17979e2b2bf9734dfd76f20b86
|
|
| MD5 |
806071cd6993654307418533eb8ca02b
|
|
| BLAKE2b-256 |
a254d77e4f764c13a81d330c08ed37fb1c1065197a0c7f25b835a72f383ac287
|