Panshi
← Services

🧪 Unit Test Generator

Paste a function or module and get a runnable unit-test suite covering the happy path, boundaries, invalid inputs and error paths.

See the quality — a real example

Sample only · no credits used

Input — function under test

Framework: pytest

def apply_discount(price, percent):
    """Return price after a percent discount, rounded to 2dp."""
    if price < 0:
        raise ValueError("price must be non-negative")
    if not 0 <= percent <= 100:
        raise ValueError("percent must be 0..100")
    return round(price * (1 - percent / 100), 2)

Output — generated test suite

import pytest
from pricing import apply_discount

def test_basic_discount():
    assert apply_discount(100.0, 20) == 80.0

def test_rounds_to_two_dp():
    assert apply_discount(9.99, 15) == 8.49

def test_zero_percent_is_unchanged():
    assert apply_discount(50.0, 0) == 50.0

def test_full_discount_is_zero():
    assert apply_discount(50.0, 100) == 0.0

def test_negative_price_raises():
    with pytest.raises(ValueError):
        apply_discount(-1.0, 10)

@pytest.mark.parametrize("p", [-5, 101])
def test_percent_out_of_range_raises(p):
    with pytest.raises(ValueError):
        apply_discount(100.0, p)

Cases covered

  • test_basic_discount — happy path, 20% off 100
  • test_rounds_to_two_dp — rounding to 2 decimal places
  • test_zero/full_discount — boundaries at 0% and 100%
  • test_negative_price_raises — invalid input error path
  • test_percent_out_of_range_raises — parametrized −5 and 101

Note: import path assumed to be pricing — adjust to your module. We flag assumptions instead of guessing silently.

Related tools

Text to SQL

Turn plain English into correct SQL for Postgres, MySQL, SQLite, BigQuery or Snowflake — schema-aware.

Code Review

Paste a diff or file and get a ranked review — bugs, logic, security, performance — with fixes.

Excel Formula

Describe what you need and get the exact Excel / Google Sheets formula — with a plain-language explanation.

Legacy Code Explainer

Paste unfamiliar code and get a plain-English walkthrough, data flow and risks.

FAQ

How much does Unit Test Generator cost?

About 9 points per run (1 point = $0.01). You get 30 free points on signup to try it. No subscription — pay only for what you run, and points never expire.

Is my data private?

Your input is used only to generate this one result; results are saved to your own account history, never shared and never used to train models.

What if the result isn’t good?

If a tool fails to deliver a usable result within 14 days, we refund or re-credit it — just email hi@panshi.io.

Do I need a subscription?

No. Buy points once, use them on every tool, no monthly fee, and they never expire.