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:
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
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.
guttwill skip code generation if the test templates for the functions already exist.guttwon'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
guttto 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 =============================
Metadata
Release files for gutt 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gutt-1.2.0.tar.gz | 9.0 kB | Without provenance | Details for gutt-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gutt-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for gutt-1.2.0-py3-none-any.whl |
Total release size: 19.0 kB
Release files / gutt-1.2.0.tar.gz
| Download URL | gutt-1.2.0.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12f434dfbbd5b4c0e3222c0e1c1810ea6e0a5d86117b482214414313880acbd7
|
|
BLAKE2b-256 checksum How to use checksums |
b83733225b3e606f7c4d73157e1449b06383a2e433dc3d41584c3e92b875199a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.20.1 CPython/3.8.5 Linux/4.15.0-213-generic
|
Release files / gutt-1.2.0-py3-none-any.whl
| Download URL | gutt-1.2.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58e84719418e3036e300aaf2003320864cc72f18b0f01ba99ca79cec7bc91202
|
|
BLAKE2b-256 checksum How to use checksums |
f0294a813bef7614feb70b8ae2f4f70010f756e981c3709924c9977294845c9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.20.1 CPython/3.8.5 Linux/4.15.0-213-generic
|
Security for gutt 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.