A Gradio-based web application that automatically generates unit tests for Python code using OpenAI's GPT-4o-mini API and runs them !
- Web-based interface for submitting Python code
- Automated unit test generation using GPT-4o-mini
- Real-time test generation and display
- Simple and intuitive user interface
Before running this application, make sure you have:
- Python 3.8 or higher
- Clone the repository:
git clone https://github.com/yourusername/python-unit-test-generator.git
cd python-unit-test-generator/src- Install the required dependencies:
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txtpython-unit-test-generator/
├── src/
│ ├── config.py # Configuration and environment variables
│ ├── api_client.py # OpenAI API interaction logic
│ ├── ui.py # Gradio UI implementation
│ ├── main.py # Application entry point
│ └── system_prompt.txt # System prompt for GPT-4
├── requirements.txt # Project dependencies
└── README.md # Project documentation
- Start the application:
python main.py-
Open your web browser and navigate to the URL displayed in the terminal
-
Enter your Python code in the text input field
-
Click "Submit" to generate unit tests
config.py: Handles environment variables and configuration settingsapi_client.py: Manages communication with the OpenAI APIui.py: Contains the Gradio web interface implementationmain.py: Application entry point and initialization
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for providing the GPT-4 API
- Gradio team for the web interface framework