This project is a Python-based repository designed to demonstrate and test various functionalities using unit testing. It includes multiple modules, each focusing on specific tasks, and is containerized using Docker for ease of deployment and testing.
-
unittesting_efficiency.py- Contains the
FibonacciSequenceclass with two methods to compute Fibonacci numbers:recursive_method: Uses recursion to calculate Fibonacci numbers.math_method: Uses a mathematical formula for computation.
- Contains the
-
unittesting_counter.py- Provides a
count_lettersfunction to count the number of letters in a string, excluding spaces and non-alphabetical characters.
- Provides a
-
unittesting_console_output.py- Defines a
Profileclass with attributes (age,job,name) and methods to print these attributes.
- Defines a
-
unittesting_classes.py- Contains a
Counterclass to increment, decrement, reset, and retrieve a numerical value.
- Contains a
-
unittesting_car_class.py- Implements a
Carclass with attributes likespeed,passengers, and methods to manage car operations such as turning on/off, adding/subtracting passengers, and adjusting speed.
- Implements a
-
unittesting_base.py- Provides a utility function
str_to_uppercaseto convert a string to uppercase.
- Provides a utility function
-
unittesting_average.py- Contains a
calculate_averagefunction to compute the average of a list of integers or floats.
- Contains a
requirements.txt: Lists Python dependencies required for the project.Dockerfile: Defines the containerization setup for the project.docker-compose.yml: Configures the Docker Compose setup for building and running the project.docker-compose.debug.yml: Adds debugging capabilities to the Docker Compose setup..vscode/tasks.json: Contains VS Code tasks for building and running the Docker container..vscode/settings.json: Configures Python testing settings for the project.
.gitignore: Specifies files and directories to exclude from version control..dockerignore: Specifies files and directories to exclude from the Docker build context.
- Python 3.x
- Docker and Docker Compose
-
Clone the repository:
git clone <repository-url> cd unittesting_project
-
Install dependencies:
pip install -r requirements.txt
-
Using Docker:
- Build and run the container:
docker-compose up --build
- Build and run the container:
-
Debugging with Docker:
- Use the debug configuration:
docker-compose -f docker-compose.debug.yml up --build
- Use the debug configuration:
-
Running Locally:
- Execute individual Python scripts or run tests using:
python <script_name>.py
- Execute individual Python scripts or run tests using:
- The project uses
unittestfor testing. To run the tests:python -m unittest discover -s ./tests -p "*_test.py"
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request with a detailed description of your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
- Special thanks to the developers and maintainers of the libraries used in this project.
- Inspired by the need for efficient and modular unit testing practices.