unitgen
Generate unit tests boilerplate code
This is a simple tool to generate boilerplate code for unit tests. It is for those developers who are not able to follow TDD (Test Driven Development) for few methods and want to write unit tests for them after writing the actual code.
All the test files are generated in a folder named "tests" if it does not exist.
Example: examples/calci.py
import math
class Calci:
def __init__(self):
print("Calci class created")
def add(self, a, b=0):
c = a + b
return c
def sub(self, a, b):
return a - b
class StringCalci:
def concat(self, a, b):
return a + b
def repeat(self, a, b):
return a * b
Run unitgen from command line:
# View how to use unitgen
unitgen
# all files under examples directory are processed
unitgen examples
# Files calci.py and pay_handler.py are processed
unitgen examples/calci.py examples/pay_handler.py
Generated result: tests/test_calci.py
from unittest import TestCase
from examples.calci import Calci, StringCalci
class TestCalci(TestCase):
def setUp(self):
""" Set up objects for each test """
self.calci = Calci()
def test___init__(self):
""" Test initialiser """
self.obj = Calci()
def test_add(self):
a = None
b = None
actual_result = self.calci.add(a, b)
expected_result = None
self.assertEqual(actual_result, expected_result)
def test_sub(self):
a = None
b = None
actual_result = self.calci.sub(a, b)
expected_result = None
self.assertEqual(actual_result, expected_result)
def tearDown(self):
""" Destroy objects after each test """
class TestStringCalci(TestCase):
def setUp(self):
""" Set up objects for each test """
self.string_calci = StringCalci()
def test_concat(self):
a = None
b = None
actual_result = self.string_calci.concat(a, b)
expected_result = None
self.assertEqual(actual_result, expected_result)
def test_repeat(self):
a = None
b = None
actual_result = self.string_calci.repeat(a, b)
expected_result = None
self.assertEqual(actual_result, expected_result)
def tearDown(self):
""" Destroy objects after each test """
Enjoy!
My Github profile: susmitpy
My Linkedin profile: susmit vengurlekar
My Medium profile: susmit.py
Metadata
Release files for unitgen 1.2
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 |
|---|---|---|---|---|
| unitgen-1.2.tar.gz | 4.2 kB | Without provenance | Details for unitgen-1.2.tar.gz |
Release files / unitgen-1.2.tar.gz
| Download URL | unitgen-1.2.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55ad6304f83227e2bb3e7a5418ac3373a540e8aeed3178c9c620b41210d10f15
|
|
BLAKE2b-256 checksum How to use checksums |
d676f1641d97ee78e6272889302c72d94408a64f86e3a1cd732f0a296521d44b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/1.6.1 pkginfo/1.8.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.6
|
Security for unitgen 1.2
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.