python ut test code generator.
Project description
Python UT generator
This tools generate automatically Python pytest Unit test code.
This project uses ast module to generate.
Easy to make coverage test.
feature
- Generate unit test python file in tests package.
- Generate pytest test function from each function.
- Generate mock patch syntax code.
- Generate argument syntax code to call.
- if function has return value, create assert return.
Installation
install pip
pip install pyutgenerator
https://pypi.org/project/pyutgenerator/
Run tool.
genarete test code
pyutgen "Input File Name"
sample input file
import os
def aaaaa():
"""
call and return
"""
return os.path.exists('')
sample out put
import pytest
from unittest.mock import patch
from unittest.mock import MagicMock
from tests.pyutgenerator.data import pattern01
def test_aaaaa():
# plan
# do
with\
patch('tests.pyutgenerator.data.pattern01.os.path') as m1:
m1.return_value = None
m1.exists = MagicMock(return_value=None)
ret = pattern01.aaaaa()
# check
assert ret
for future
- regist pypi.
- customize parameter options.
- parameter type for str,list, obj ...
- write return_value.
- exception check.
- call default and pass test.
- genarete various parameters for test.
- web ui for test.
Prerequisites
not yet
not yet
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
- Hat tip to anyone whose code was used
- Inspiration
- etc
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyutgenerator-0.5.0.tar.gz
(7.5 kB
view hashes)
Built Distribution
Close
Hashes for pyutgenerator-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2475782743e04020aa8275a3d9207caf67a313b2cdcb8b288147ab74243280b |
|
MD5 | a4b4a0666dc91f721f69cb057231054d |
|
BLAKE2b-256 | ca74873a45f5d6986d97762d19577efdd933653b01f4066461012e8c72a0f60f |