Getting tired of manually writing unit test stubs for your Python code? Easy.
Example
# file: example.py
def testable_func(arg_one, arg_two):
pass
class AClass:
def __init__(self, some, constructor, params):
pass
def testable_func_in_class(self, an_arg):
pass
$ pytestgen example.py
# file: test_example.py
import pytest
import example
@pytest.mark.parametrize(
"arg_one,arg_two,expected",
[
# TODO: fill in test data for test_testable_func
# pytest.param(, , id="")
]
)
def test_testable_func(arg_one, arg_two, expected):
# TODO: create assertions for test_testable_func
# example.testable_func(arg_one, arg_two)
pass
@pytest.mark.parametrize(
"instance,an_arg,expected",
[
# TODO: fill in test data for test_aclass_testable_func_in_class
# pytest.param(example.AClass(some, constructor, params), , expected, id="")
]
)
def test_aclass_testable_func_in_class(instance, an_arg, expected):
# TODO: write test for test_aclass_testable_func_in_class
# TODO: create assertions for test_aclass_testable_func_in_class
# instance.testable_func_in_class(an_arg)
pass
Installation
$ pip install pytestgen
Usage
# generate tests for directory 'my_package' in 'tests/' directory
$ pytestgen my_package
# generate tests for some python files and directory 'the_package'
$ pytestgen my_module_a.py another_module.py the_package
# generate tests for directory 'cool_app' in 'cool_tests/' directory
$ pytestgen cool_app -o cool_tests
# generate tests for functions 'foo' and 'bar' in 'functionality.py'
$ pytestgen functionality.py -i foo -i bar
Full usage text
Usage: pytestgen [OPTIONS] PATH...
Generate pytest unit tests from your Python source code.
Options:
-o, --output-dir PATH The path to generate tests in. [default: tests]
-i, --include FUNC Function names to generate tests for. You can use
this multiple times.
-h, --help Show this message and exit.
License
Metadata
Release files for pytestgen 0.1.1
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 |
|---|---|---|---|---|
| pytestgen-0.1.1.tar.gz | 8.8 kB | Without provenance | Details for pytestgen-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytestgen-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pytestgen-0.1.1-py3-none-any.whl |
Total release size: 19.6 kB
Release files / pytestgen-0.1.1.tar.gz
| Download URL | pytestgen-0.1.1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ef93357546cc3e45be913e0887cdf7315966635f055f44c099b5def58434056
|
|
BLAKE2b-256 checksum How to use checksums |
b569c23be3ac8d7500c39bcbd23357bee21433453dd5b39fd971ff20fb39b367
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6
|
Release files / pytestgen-0.1.1-py3-none-any.whl
| Download URL | pytestgen-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8aa7771f2b7ff424af05114d75e32ccacda124cd08f32f4aebb9b2fb4b192a1f
|
|
BLAKE2b-256 checksum How to use checksums |
593f45172ec794add959341741bb893551569e4720c9241d2d409eb6e669bc96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6
|
Security for pytestgen 0.1.1
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.