Auto generate unit test using PyTest and Gpt
Project description
unittest-gpt
📍 Test smarter, not harder with unittest-gpt: GPT-powered auto unit tests generator!
⚙️ Developed with the software and tools below:
⚙️ Powered by OpenAI's GPT language model APIs and the software below:
🦜️🔗
📚 Table of Contents
- 📚 Table of Contents
- 📍 Overview
- 💫 Features
- 📂 Project Structure
- 🧩 Modules
- 🚀 Getting Started
- 🗺 Roadmap
- 🤝 Contributing
- 📄 License
- 👏 Acknowledgments
📍 Overview
unittest-gpt is a powerful, user-friendly tool that automatically generates unit test files for your python repositories using OpenAI's language model APIs. By simply providing the file or a directory, unittest-gpt will automatically generate unit test for your python source code.
🚀 Getting Started
✅ Prerequisites
Before you begin, ensure that you have the following prerequisites installed:
- 📌 OPENAI - API KEY
- 📌 Python 3.11
🔐 OpenAI API Setup
To use README-AI, you will need an API key for OpenAI. Follow the steps below to create an API key:
User Guide - OpenAI API
- Go to the OpenAI website.
- Click the "Sign up for free" button.
- Fill out the registration form with your information and agree to the terms of service.
- Once logged in, click on the "API" tab.
- Follow the instructions to create a new API key.
- Copy the API key and keep it in a secure place.
🖥 Installation
- Clone the unittest-gpt repository:
git clone ../unittest-gpt
- Change to the project directory:
cd unittest-gpt
- Setup up a venv (the least resistance way to get started quickly)
- if you don't have virtualenv install run the first command
pip install virtualenv
virtualenv venv
source venv/bin/activate
- Install the dependencies:
pip install -r requirements.txt
🤖 Using unittest-gpt as cli
python unit_test_agent.py -f <file_name>
python unit_test_agent.py -dir <dir_name>
#example
python unit_test_agent.py -f test.py
python unit_test_agent.py -dir src
🤖 Using unittest-gpt in your project
unit_test_agent = UnitTestAgent()
# Call the method with the file parameter
unit_test_agent.generate_testcases(file="<file_name>")
# Call the method with the directory parameter
unit_test_agent.generate_testcases(path="<directory>")
🧪 Running Tests
Run below command in the root directory
pytest
🤝 Contributing
Contributions are always welcome! Please follow these steps:
- Fork the project repository. This creates a copy of the project on your account that you can modify without affecting the original project.
- Clone the forked repository to your local machine using a Git client like Git or GitHub Desktop.
- Create a new branch with a descriptive name (e.g.,
new-feature-branch
orbugfix-issue-123
).
git checkout -b new-feature-branch
- Make changes to the project's codebase.
- Commit your changes to your local branch with a clear commit message that explains the changes you've made.
git commit -m 'Implemented new feature.'
- Push your changes to your forked repository on GitHub using the following command
git push origin new-feature-branch
- Create a pull request to the original repository. Open a new pull request to the original project repository. In the pull request, describe the changes you've made and why they're necessary. The project maintainers will review your changes and provide feedback or merge them into the main branch.
📄 License
This project is licensed under the MIT License
License. See the LICENSE file for additional info.
👏 Acknowledgments
- hwchase17/langchain wouldn't have built without langchain.
- gkamradt/langchain-tutorials his videos are inspiring and open your imagination to build cool things.
- eli64s/README-AI thanks for helping me set up a quick readme.md file. Will use it for all projects going forward.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for unittest_gpt-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6088c2010390ea02e8c133003e388a3bb64bac5b9eaf4283b4ab85d0204ea649 |
|
MD5 | c521f50d843602528800fd5e3bd94ba0 |
|
BLAKE2b-256 | 8fbe75c8a7ad70c4597eb73cbdae538c9aacdf104d5a740c7f4cdd493a4b7a5e |