{"id":20051565,"url":"https://github.com/ryanchao2012/gutt","last_synced_at":"2025-05-05T11:31:44.806Z","repository":{"id":43354680,"uuid":"352398120","full_name":"ryanchao2012/gutt","owner":"ryanchao2012","description":"Auto Generate Unit Test Templates","archived":false,"fork":false,"pushed_at":"2025-01-31T19:42:48.000Z","size":127,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-28T14:54:45.787Z","etag":null,"topics":["code-generation","codegen","gutt","python","testing","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanchao2012.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-28T17:49:23.000Z","updated_at":"2025-01-31T19:42:52.000Z","dependencies_parsed_at":"2022-08-20T00:40:41.513Z","dependency_job_id":null,"html_url":"https://github.com/ryanchao2012/gutt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanchao2012%2Fgutt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanchao2012%2Fgutt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanchao2012%2Fgutt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanchao2012%2Fgutt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanchao2012","download_url":"https://codeload.github.com/ryanchao2012/gutt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252489055,"owners_count":21756256,"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":["code-generation","codegen","gutt","python","testing","unit-testing"],"created_at":"2024-11-13T12:03:56.605Z","updated_at":"2025-05-05T11:31:44.295Z","avatar_url":"https://github.com/ryanchao2012.png","language":"Python","readme":"![](https://github.com/ryanchao2012/gutt/actions/workflows/gutt-run-unittests.yml/badge.svg)\n![](https://img.shields.io/pypi/v/gutt.svg)\n![](https://img.shields.io/pypi/pyversions/gutt)\n![](https://img.shields.io/github/license/ryanchao2012/gutt)\n\n# gutt\nAuto Generate Unit Test Templates\n\n\n## Install\n\n```\n$ pip install gutt\n```\n\n\n## Basic Usage\n\nAssume you have a package, and its layout:\n\n```\nmy_awesome_package\n├── __init__.py\n└── module1.py\n```\n\nsome codes inside `my_awesome_package/module1.py`:\n\n```python\n\nimport sys\n\nMY_CONST = 123\n\ndef funcion1():\n    pass\n\n\ndef function2():\n    pass\n\n\nclass MyObject:\n    def method1(self):\n        pass\n\n    @classmethod\n    def classmethod1(cls):\n        pass\n\n    @staticmethod\n    def staticmethod1():\n        pass\n\n```\n\n`gutt` can generate unit testing templates for all implementations in just one line:\n\n```\n$ gutt -m my_awesome_package -o mytests\n```\n\nThe output layout:\n\n```\nmytests\n├── __init__.py\n└── my_awesome_package\n    ├── __init__.py\n    └── test_module1.py\n\n```\n\nThe unit test templates inside `test_module1.py`\n\n```python\ndef test_funcion1():\n    from my_awesome_package.module1 import funcion1\n\n    assert funcion1\n\n\ndef test_function2():\n    from my_awesome_package.module1 import function2\n\n    assert function2\n\n\nclass TestMyObject:\n    @classmethod\n    def setup_class(cls):\n        from my_awesome_package.module1 import MyObject\n\n        assert MyObject\n\n    @classmethod\n    def teardown_class(cls):\n        pass\n\n    def setup_method(self, method):\n        pass\n\n    def teardown_method(self, method):\n        pass\n\n    def test_method1(self):\n        pass\n\n    def test_classmethod1(self):\n        pass\n\n    def test_staticmethod1(self):\n        pass\n\n```\n\nEach module in source codes maps to a testing module(`module1.py --\u003e test_module1.py`), and each function, each class and all methods inside that class maps to corresponding test templates. \n\n- `gutt` will skip code generation if the test templates for the functions already exist.\n- `gutt` won't delete the corresponding test templates if the source codes get deleted or renamed.\n- For new added codes: modules, functions or methods inside class, just re-run `gutt` to generate new test templates for them.\n\n\nRun unit test with `pytest`, for example:\n\n```\n$ pytest --doctest-modules --cov=my_awesome_package mytests\n\n=============================== test session starts ===============================\nplatform linux -- Python 3.8.8, pytest-4.6.11, py-1.10.0, pluggy-0.13.1\nrootdir: /home/ryan/Workspace/my_awesome_package\nplugins: mock-1.13.0, cov-2.11.1\ncollected 5 items                                                                 \n\nmytests/my_awesome_package/test_module1.py .....                            [100%]\n\n----------- coverage: platform linux, python 3.8.8-final-0 -----------\nName                             Stmts   Miss  Cover\n----------------------------------------------------\nmy_awesome_package/__init__.py       0      0   100%\nmy_awesome_package/module1.py       13      5    62%\n----------------------------------------------------\nTOTAL                               13      5    62%\n\n\n============================ 5 passed in 0.07 seconds =============================\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanchao2012%2Fgutt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanchao2012%2Fgutt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanchao2012%2Fgutt/lists"}