https://github.com/ctk3b/borderline
Stop letting modules reach into other modules
https://github.com/ctk3b/borderline
python testing
Last synced: about 1 year ago
JSON representation
Stop letting modules reach into other modules
- Host: GitHub
- URL: https://github.com/ctk3b/borderline
- Owner: ctk3b
- License: mit
- Created: 2021-09-17T00:06:04.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-29T17:44:18.000Z (almost 5 years ago)
- Last Synced: 2025-02-14T18:28:02.892Z (over 1 year ago)
- Topics: python, testing
- Language: Python
- Homepage:
- Size: 55.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Borderline
Stop letting modules reach into other modules.
---

[](https://pypi.python.org/pypi/borderline/)
This library provides one thing and one thing only: a test class called `ModuleImports`
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:
```python
class TestReportBuilder(borderline.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
)
```