Skip to main content

Python UT generator

This tools generate automatically Python pytest Unit test code.
This project uses ast module to generate.
Easy to make coverage test. And Easy to customize test code.

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"

or

python -m pyutgenerator.run "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 the future

  • For Code
    • Genarete various parameters for test.
    • Write return check value.
    • 'exception' check.
    • 'with' description mock.
    • Generate test data.
    • Assertion for method call for count, parameter, throw.
    • parameter type for str,list, obj ...
    • Simple code analyst report. like no None check or Parameter
    • For django
  • Customize parameter options or setting file.
    • Exclude function mock.
    • Source directory path.
    • tab space num.
  • Get test data from debug.
  • able to run default generated code and pass test.
  • Full coverage.
  • 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

Metadata

Release files for pyutgenerator 0.11.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyutgenerator 0.11.1
File Size Uploaded Provenance Actions
pyutgenerator-0.11.1.tar.gz 10.8 kB Without provenance Details for pyutgenerator-0.11.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyutgenerator 0.11.1
File Interpreter ABI Platform Actions
pyutgenerator-0.11.1-py3-none-any.whl Python 3 none any Details for pyutgenerator-0.11.1-py3-none-any.whl

Total release size: 22.9 kB

Release files / pyutgenerator-0.11.1.tar.gz

Download URL pyutgenerator-0.11.1.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
547052b2fff2fe6993b2a0b4c2ec5660bb3c6443b8ed7804434a16de8acf1dbc
BLAKE2b-256 checksum
How to use checksums
b4852d1112b7c3afec5016214d3e5b27d18ffdd6be04cb279ca00679f548db0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.9.12 Windows/10

Release files / pyutgenerator-0.11.1-py3-none-any.whl

Download URL pyutgenerator-0.11.1-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e62db31c3bc3b83f1c3388704b021832408dea7e70aadb854d4bc31a6a450e3c
BLAKE2b-256 checksum
How to use checksums
57f02677caa393e3622945e7f56cab72a0e51496be84a0d72e985a65c80711de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.9.12 Windows/10

Security for pyutgenerator 0.11.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page