pytestarch


Namepytestarch JSON
Version 3.1.1 PyPI version JSON
download
home_pagehttps://github.com/zyskarch/pytestarch
SummaryTest framework for software architecture based on imports between modules
upload_time2024-10-02 18:16:06
maintainerzyskarch
docs_urlNone
authorzyskarch
requires_python<4.0,>=3.9
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": "<4.0,>=3.9",
    "maintainer_email": "zyskarch@gmail.com",
    "keywords": "architecture, test",
    "author": "zyskarch",
    "author_email": "zyskarch@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e3/2c/676e6bd6db4a73d0b7bfedf157fc9dddc3f49f41c7adef7eb94d5999f2c4/pytestarch-3.1.1.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\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Test framework for software architecture based on imports between modules",
    "version": "3.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/zyskarch/pytestarch/issues",
        "Documentation": "https://zyskarch.github.io/pytestarch/latest",
        "Homepage": "https://github.com/zyskarch/pytestarch",
        "Repository": "https://github.com/zyskarch/pytestarch"
    },
    "split_keywords": [
        "architecture",
        " test"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "777ee4d0ce0349b0ff23d1de190763699dc0ca7e250cb6a0650f8391ae7b0fe8",
                "md5": "187084d9a9bf0b6203fde0e587deb6cf",
                "sha256": "bdd14001a178faa5f01908b35891582f3c6deba30b2ae4898cdfb128a2be31f6"
            },
            "downloads": -1,
            "filename": "pytestarch-3.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "187084d9a9bf0b6203fde0e587deb6cf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 61932,
            "upload_time": "2024-10-02T18:16:04",
            "upload_time_iso_8601": "2024-10-02T18:16:04.294357Z",
            "url": "https://files.pythonhosted.org/packages/77/7e/e4d0ce0349b0ff23d1de190763699dc0ca7e250cb6a0650f8391ae7b0fe8/pytestarch-3.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e32c676e6bd6db4a73d0b7bfedf157fc9dddc3f49f41c7adef7eb94d5999f2c4",
                "md5": "abd254c77ead5fae51966f263562c21c",
                "sha256": "aca758b59d180a198cf50104a861a6b54e3302fd12f6e5dcd3e211ddb08147a4"
            },
            "downloads": -1,
            "filename": "pytestarch-3.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "abd254c77ead5fae51966f263562c21c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 44372,
            "upload_time": "2024-10-02T18:16:06",
            "upload_time_iso_8601": "2024-10-02T18:16:06.163307Z",
            "url": "https://files.pythonhosted.org/packages/e3/2c/676e6bd6db4a73d0b7bfedf157fc9dddc3f49f41c7adef7eb94d5999f2c4/pytestarch-3.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-02 18:16:06",
    "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.75624s