{"id":23413179,"url":"https://github.com/okorolev/pytest-ast-transformer","last_synced_at":"2025-07-11T10:02:41.104Z","repository":{"id":62583977,"uuid":"152261494","full_name":"okorolev/pytest-ast-transformer","owner":"okorolev","description":"AST Transformer for tests integrated with py.test.","archived":false,"fork":false,"pushed_at":"2019-05-04T16:50:01.000Z","size":41,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-12T23:25:25.699Z","etag":null,"topics":["ast","ast-transformations","debug","magic","pytest","pytest-plugin","python3","refactoring","testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/okorolev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-09T14:03:36.000Z","updated_at":"2023-12-09T06:17:14.000Z","dependencies_parsed_at":"2022-11-03T21:37:20.434Z","dependency_job_id":null,"html_url":"https://github.com/okorolev/pytest-ast-transformer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/okorolev/pytest-ast-transformer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okorolev%2Fpytest-ast-transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okorolev%2Fpytest-ast-transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okorolev%2Fpytest-ast-transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okorolev%2Fpytest-ast-transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okorolev","download_url":"https://codeload.github.com/okorolev/pytest-ast-transformer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okorolev%2Fpytest-ast-transformer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264780292,"owners_count":23662615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","ast-transformations","debug","magic","pytest","pytest-plugin","python3","refactoring","testing"],"created_at":"2024-12-22T19:25:58.902Z","updated_at":"2025-07-11T10:02:40.833Z","avatar_url":"https://github.com/okorolev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/okorolev/pytest-ast-transformer.svg?branch=master)](https://travis-ci.org/okorolev/pytest-ast-transformer)\n[![image](https://img.shields.io/pypi/v/pytest-ast-transformer.svg)](https://pypi.org/project/pytest-ast-transformer/)\n\n## About\nAST Transformer integrated with py.test.\n\nUseful for debug, refactoring, 'clean asserts' (see [examples/replace_asserts](examples/replace_asserts))\n\nSupport options\n---------------\n| Options                  | Description                    |\n| -----------              | -----------                    |\n| `--show-code`            | show generated code            |\n| `--disable-transforms`   | disable all ast transformers   |\n\n## Install\n```bash\npip install pytest-ast-transformer\n```\n\n## Usage\n\n* Write ast transformer\n    ```python\n    # transformer.py\n    import ast\n\n    from pytest_ast_transformer.ast_transformer import PytestTransformer\n\n\n    def my_assert(test_result, msg=''):\n        print(f'my assert: {test_result} {msg}')\n        assert test_result, msg\n\n\n    class AssertTransformer(PytestTransformer):\n        context = {\n            'my_assert': my_assert\n        }\n\n        def visit_Assert(self, node: ast.Assert) -\u003e ast.Expr:\n            func_name = ast.Name(id='my_assert', ctx=ast.Load())\n            call_func = ast.Call(func=func_name, args=[node.test, node.msg], keywords=[])\n            expr = ast.Expr(value=call_func)\n\n            return ast.fix_missing_locations(expr)\n    ```\n* Register new ast transformer\n    ```python\n    # conftest.py\n    from pytest_ast_transformer.ast_manager import ASTManager\n    from tests.transformer import AssertTransformer\n    \n    \n    def pytest_register_ast_transformer(ast_manager: ASTManager):\n        ast_manager.add_transformer(AssertTransformer())\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokorolev%2Fpytest-ast-transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokorolev%2Fpytest-ast-transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokorolev%2Fpytest-ast-transformer/lists"}