pytestarch


Namepytestarch JSON
Version 2.0.3 PyPI version JSON
download
home_pagehttps://github.com/zyskarch/pytestarch
SummaryTest framework for software architecture based on imports between modules
upload_time2024-03-17 09:00:43
maintainerzyskarch
docs_urlNone
authorzyskarch
requires_python>=3.8,<4.0
licenseApache-2.0
keywords architecture test
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Welcome to PyTestArch

PyTestArch is an open source library that allows users to define architectural rules and test their code against them. It is 
generally inspired by [ArchUnit](https://www.archunit.org/).

## Installation Guide
PyTestArch is available via [PyPI](https://pypi.org/project/pytestarch/) and can be installed e.g. via pip: `pip install pytestarch`. To also install the
optional dependency matplotlib, which is required to draw the created dependency graphs, install `pytestarch[visualization]`

## Usage Guide
Three steps are required to test an architectural rule:

1) Create an evaluable representation of the source code you want to test

```
from pytestarch import get_evaluable_architecture

evaluable = get_evaluable_architecture("/home/dummy/project", "/home/dummy/project/src")
```
This will scan all python files under /home/dummy/project/src for imports and build an internal representation that can
later be queried. The first parameter /home/dummy/project helps PyTestArch to differentiate between internal and external 
dependencies. This evaluable can be used for multiple architectural rule checks; if you are using [pytest](https://docs.pytest.org/en/7.1.x/),
you could use a fixture for this evaluable object.

2) Define an architectural rule
```
from pytestarch import Rule

rule = (
    Rule() 
    .modules_that() 
    .are_named("project.src.moduleB") 
    .should_not() 
    .be_imported_by_modules_that() 
    .are_sub_modules_of("project.src.moduleA") 
)
```

This rule represents the architectural requirements that a module named "project.src.moduleB" should not be imported by any module
that is a submodule of "project.src.moduleA", excluding "project.src.moduleA" itself.

3) Evaluate your code against this rule

```
rule.assert_applies(evaluable)
```
That's it!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zyskarch/pytestarch",
    "name": "pytestarch",
    "maintainer": "zyskarch",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "zyskarch@gmail.com",
    "keywords": "architecture,test",
    "author": "zyskarch",
    "author_email": "zyskarch@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c3/a3/daff482da38bb6fc1789374a39b625939320baf8c4a37e865e81f9b71106/pytestarch-2.0.3.tar.gz",
    "platform": null,
    "description": "# Welcome to PyTestArch\n\nPyTestArch is an open source library that allows users to define architectural rules and test their code against them. It is \ngenerally inspired by [ArchUnit](https://www.archunit.org/).\n\n## Installation Guide\nPyTestArch is available via [PyPI](https://pypi.org/project/pytestarch/) and can be installed e.g. via pip: `pip install pytestarch`. To also install the\noptional dependency matplotlib, which is required to draw the created dependency graphs, install `pytestarch[visualization]`\n\n## Usage Guide\nThree steps are required to test an architectural rule:\n\n1) Create an evaluable representation of the source code you want to test\n\n```\nfrom pytestarch import get_evaluable_architecture\n\nevaluable = get_evaluable_architecture(\"/home/dummy/project\", \"/home/dummy/project/src\")\n```\nThis will scan all python files under /home/dummy/project/src for imports and build an internal representation that can\nlater be queried. The first parameter /home/dummy/project helps PyTestArch to differentiate between internal and external \ndependencies. This evaluable can be used for multiple architectural rule checks; if you are using [pytest](https://docs.pytest.org/en/7.1.x/),\nyou could use a fixture for this evaluable object.\n\n2) Define an architectural rule\n```\nfrom pytestarch import Rule\n\nrule = (\n    Rule() \n    .modules_that() \n    .are_named(\"project.src.moduleB\") \n    .should_not() \n    .be_imported_by_modules_that() \n    .are_sub_modules_of(\"project.src.moduleA\") \n)\n```\n\nThis rule represents the architectural requirements that a module named \"project.src.moduleB\" should not be imported by any module\nthat is a submodule of \"project.src.moduleA\", excluding \"project.src.moduleA\" itself.\n\n3) Evaluate your code against this rule\n\n```\nrule.assert_applies(evaluable)\n```\nThat's it!\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Test framework for software architecture based on imports between modules",
    "version": "2.0.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/zyskarch/pytestarch/issues",
        "Documentation": "https://zyskarch.github.io/pytestarch/",
        "Homepage": "https://github.com/zyskarch/pytestarch",
        "Repository": "https://github.com/zyskarch/pytestarch"
    },
    "split_keywords": [
        "architecture",
        "test"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "240155b0e456c9479879a6e12229c08d7e23e2793ddadba8646d3692c6ff3bbd",
                "md5": "92a8fbda2bad7b3727ff28e549355646",
                "sha256": "2c53fbfeaed8c3dc6b281faf5a416392068ff8064cfa18d555ccd32c19581cff"
            },
            "downloads": -1,
            "filename": "pytestarch-2.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "92a8fbda2bad7b3727ff28e549355646",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 61658,
            "upload_time": "2024-03-17T09:00:41",
            "upload_time_iso_8601": "2024-03-17T09:00:41.014338Z",
            "url": "https://files.pythonhosted.org/packages/24/01/55b0e456c9479879a6e12229c08d7e23e2793ddadba8646d3692c6ff3bbd/pytestarch-2.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c3a3daff482da38bb6fc1789374a39b625939320baf8c4a37e865e81f9b71106",
                "md5": "83097b71554336c79672eab5951e449a",
                "sha256": "f17a4ddb86581e45c503ae4d330ca5ddc2c7d39cac9974e673fc329759aa6afb"
            },
            "downloads": -1,
            "filename": "pytestarch-2.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "83097b71554336c79672eab5951e449a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 44041,
            "upload_time": "2024-03-17T09:00:43",
            "upload_time_iso_8601": "2024-03-17T09:00:43.035533Z",
            "url": "https://files.pythonhosted.org/packages/c3/a3/daff482da38bb6fc1789374a39b625939320baf8c4a37e865e81f9b71106/pytestarch-2.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-17 09:00:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zyskarch",
    "github_project": "pytestarch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pytestarch"
}
        
Elapsed time: 0.24076s