Skip to main content


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:

🦜️🔗 OpenAI Python pytest


📚 Table of Contents


📍 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
  1. Go to the OpenAI website.
  2. Click the "Sign up for free" button.
  3. Fill out the registration form with your information and agree to the terms of service.
  4. Once logged in, click on the "API" tab.
  5. Follow the instructions to create a new API key.
  6. Copy the API key and keep it in a secure place.

🖥 Installation

  1. Clone the unittest-gpt repository:
git clone ../unittest-gpt
  1. Change to the project directory:
cd unittest-gpt
  1. Setup up a venv (the least resistance way to get started quickly)
    1. if you don't have virtualenv install run the first command
pip install virtualenv 

virtualenv venv

source venv/bin/activate
  1. 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:

  1. Fork the project repository. This creates a copy of the project on your account that you can modify without affecting the original project.
  2. Clone the forked repository to your local machine using a Git client like Git or GitHub Desktop.
  3. Create a new branch with a descriptive name (e.g., new-feature-branch or bugfix-issue-123).
git checkout -b new-feature-branch
  1. Make changes to the project's codebase.
  2. 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.'
  1. Push your changes to your forked repository on GitHub using the following command
git push origin new-feature-branch
  1. 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


Metadata

Release files for unittest-gpt 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unittest-gpt 0.1.3
File Size Uploaded Provenance Actions
unittest_gpt-0.1.3.tar.gz 6.9 kB Without provenance Details for unittest_gpt-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unittest-gpt 0.1.3
File Interpreter ABI Platform Actions
unittest_gpt-0.1.3-py3-none-any.whl Python 3 none any Details for unittest_gpt-0.1.3-py3-none-any.whl

Total release size: 14.5 kB

Release files / unittest_gpt-0.1.3.tar.gz

Download URL unittest_gpt-0.1.3.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fa06fd32b4692fdcb3a8e67bb066d8854f8145021cd1999014b7bc4b87f31f29
BLAKE2b-256 checksum
How to use checksums
5d1fac8ee64b2d7559db58b785ad77656ea555ca9994926c0c61e180b33b9464
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.0 CPython/3.11.3 Darwin/22.1.0

Release files / unittest_gpt-0.1.3-py3-none-any.whl

Download URL unittest_gpt-0.1.3-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5e2a4aa06f8774268465669824eb5672b4df27e450321721a38a670d904b166
BLAKE2b-256 checksum
How to use checksums
363f49e6ffd2cbae915f44f76a5a07f560712a92a70439c69086a69b1e45d8bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.0 CPython/3.11.3 Darwin/22.1.0

Security for unittest-gpt 0.1.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page