Name | gutt JSON |
Version |
1.1.0
JSON |
| download |
home_page | https://github.com/ryanchao2012/gutt |
Summary | Auto generate unit test templates |
upload_time | 2024-01-03 13:29:14 |
maintainer | |
docs_url | None |
author | Ryan |
requires_python | >=3.7,<4.0 |
license | MIT |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|




# gutt
Auto Generate Unit Test Templates
## Install
```
$ pip install gutt
```
## Basic Usage
Assume you have a package, and its layout:
```
my_awesome_package
├── __init__.py
└── module1.py
```
some codes inside `my_awesome_package/module1.py`:
```python
import sys
MY_CONST = 123
def funcion1():
pass
def function2():
pass
class MyObject:
def method1(self):
pass
@classmethod
def classmethod1(cls):
pass
@staticmethod
def staticmethod1():
pass
```
`gutt` can generate unit testing templates for all implementations in just one line:
```
$ gutt -m my_awesome_package -o mytests
```
The output layout:
```
mytests
├── __init__.py
└── my_awesome_package
├── __init__.py
└── test_module1.py
```
The unit test templates inside `test_module1.py`
```python
def test_funcion1():
from my_awesome_package.module1 import funcion1
assert funcion1
def test_function2():
from my_awesome_package.module1 import function2
assert function2
class TestMyObject:
@classmethod
def setup_class(cls):
from my_awesome_package.module1 import MyObject
assert MyObject
@classmethod
def teardown_class(cls):
pass
def setup_method(self, method):
pass
def teardown_method(self, method):
pass
def test_method1(self):
pass
def test_classmethod1(self):
pass
def test_staticmethod1(self):
pass
```
Each module in source codes maps to a testing module(`module1.py --> test_module1.py`), and each function, each class and all methods inside that class maps to corresponding test templates.
- `gutt` will skip code generation if the test templates for the functions already exist.
- `gutt` won't delete the corresponding test templates if the source codes get deleted or renamed.
- For new added codes: modules, functions or methods inside class, just re-run `gutt` to generate new test templates for them.
Run unit test with `pytest`, for example:
```
$ pytest --doctest-modules --cov=my_awesome_package mytests
=============================== test session starts ===============================
platform linux -- Python 3.8.8, pytest-4.6.11, py-1.10.0, pluggy-0.13.1
rootdir: /home/ryan/Workspace/my_awesome_package
plugins: mock-1.13.0, cov-2.11.1
collected 5 items
mytests/my_awesome_package/test_module1.py ..... [100%]
----------- coverage: platform linux, python 3.8.8-final-0 -----------
Name Stmts Miss Cover
----------------------------------------------------
my_awesome_package/__init__.py 0 0 100%
my_awesome_package/module1.py 13 5 62%
----------------------------------------------------
TOTAL 13 5 62%
============================ 5 passed in 0.07 seconds =============================
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ryanchao2012/gutt",
"name": "gutt",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Ryan",
"author_email": "ryanchao2012@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d5/9a/e24f714f726d778ac97d4e2c57d910d2042d88dfa7e2b39d13d10af8719e/gutt-1.1.0.tar.gz",
"platform": null,
"description": "\n\n\n\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\u251c\u2500\u2500 __init__.py\n\u2514\u2500\u2500 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\u251c\u2500\u2500 __init__.py\n\u2514\u2500\u2500 my_awesome_package\n \u251c\u2500\u2500 __init__.py\n \u2514\u2500\u2500 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 --> 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```",
"bugtrack_url": null,
"license": "MIT",
"summary": "Auto generate unit test templates",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://github.com/ryanchao2012/gutt",
"Repository": "https://github.com/ryanchao2012/gutt"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "959eae94f572f06327888d787959b05a2afe504bb9d6d2a43b3cd1c6886a5ef5",
"md5": "f5e1185f6fd28635dcdd1a86468bc3fe",
"sha256": "2ef42cfe3c9d5d25bcd0c7a5b54081ce2750a719c86394f9b53dba5f28129d9c"
},
"downloads": -1,
"filename": "gutt-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f5e1185f6fd28635dcdd1a86468bc3fe",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 9887,
"upload_time": "2024-01-03T13:29:11",
"upload_time_iso_8601": "2024-01-03T13:29:11.222383Z",
"url": "https://files.pythonhosted.org/packages/95/9e/ae94f572f06327888d787959b05a2afe504bb9d6d2a43b3cd1c6886a5ef5/gutt-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d59ae24f714f726d778ac97d4e2c57d910d2042d88dfa7e2b39d13d10af8719e",
"md5": "f6e7db06b6bf9f7980f40290ffdae5c3",
"sha256": "6e3da89a1200e4478c3a871f853ce69c807010cb77018631e397a6045b1f37f1"
},
"downloads": -1,
"filename": "gutt-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "f6e7db06b6bf9f7980f40290ffdae5c3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 8920,
"upload_time": "2024-01-03T13:29:14",
"upload_time_iso_8601": "2024-01-03T13:29:14.657925Z",
"url": "https://files.pythonhosted.org/packages/d5/9a/e24f714f726d778ac97d4e2c57d910d2042d88dfa7e2b39d13d10af8719e/gutt-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-03 13:29:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ryanchao2012",
"github_project": "gutt",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "gutt"
}