A web application that analyzes Python code, generates test cases, and provides code quality insights.
- Automatic function detection
- Type hint analysis
- Complexity metrics calculation
- Code quality suggestions
- Best practice recommendations
- Generates edge cases based on type hints
- Supports multiple test categories:
- Boundary cases
- Edge cases
- Error cases
- Export tests in different formats (pytest/unittest)
- Interactive code editor with syntax highlighting
- Dark/Light theme toggle
- Split view layout
- Collapsible test case sections
- Copy-to-clipboard functionality
- Test case filtering by category
python_test_generator/
├── app.py # Main Flask application
├── templates/
│ └── index.html # Main HTML template
├── static/
│ ├── css/
│ │ └── style.css # Custom styles
│ └── js/
│ └── main.js # Frontend functionality
└── requirements.txt # Project dependencies
- Clone the repository
git clone
cd python_test_generator
- Create and activate virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# Unix/MacOS
source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
- Start the Flask server
python app.py
- Open your browser and navigate to
http://localhost:5000
def calculate_discount(price: int, discount_percentage: int) -> float:
if discount_percentage < 0 or discount_percentage > 100:
raise ValueError("Discount percentage must be between 0 and 100")
return price * (1 - discount_percentage / 100)
def test_calculate_discount_boundary():
try:
result = calculate_discount(0, discount_percentage)
assert result is not None
except Exception as e:
pass
def test_calculate_discount_edge():
try:
result = calculate_discount(-1, discount_percentage)
assert result is not None
except Exception as e:
pass
- Flask==3.0.0
- radon==3.2.6
- Function detection using Python's AST
- Type hint analysis for parameters and return types
- Cyclomatic complexity calculation
- Code quality suggestions including:
- Missing docstrings
- Missing type hints
- Function complexity warnings
- Generates test cases based on parameter types
- Supports different test categories
- Handles edge cases for common data types:
- Integers (0, -1, MAX_INT)
- Strings (empty, very long, special characters)
- Lists (empty, large, None values)
- Syntax highlighting using CodeMirror
- Real-time code analysis
- Theme switching (light/dark)
- Test case organization and filtering
- Export functionality