Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akhtar21yr/python-unittest
in this repo we use the unittest module to test all method of built-in-datatypes
https://github.com/akhtar21yr/python-unittest
Last synced: about 2 months ago
JSON representation
in this repo we use the unittest module to test all method of built-in-datatypes
- Host: GitHub
- URL: https://github.com/akhtar21yr/python-unittest
- Owner: Akhtar21yr
- License: gpl-3.0
- Created: 2024-02-07T10:44:48.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-07T11:22:23.000Z (11 months ago)
- Last Synced: 2024-02-08T11:56:18.062Z (11 months ago)
- Language: Python
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Python Unit Test
![Alt text](https://mattermost.com/wp-content/uploads/2022/04/[email protected])
## Unit Tests
### What are Unit Tests?
Unit tests are a type of software testing where individual units or components of a software are tested. The purpose is to validate that each unit of the software performs as designed. It helps identify and fix bugs early in the development process.
### Running Unit Tests
To run the unit tests for this project, follow these steps:
1. Ensure that Python is installed on your system.
2. Open a terminal or command prompt.
3. Navigate to the project directory.
4. Run the following command:```bash
python -m unittest discover -v
```This command will discover and run all the unit tests in the project.
### Test Organization
- **code**: Contains the main source code of the project.
- **test**: Contains unit tests for the code.## About Our Code
### Overview
The primary purpose of this project is to provide comprehensive unit testing for essential string, list, tuple, dictionary, and set methods. Through a systematic set of test cases, this code ensures the correctness and reliability of these fundamental operations, offering developers a robust foundation for their Python projects.
## String Operations :
### Reverse String: Verify the accuracy of reversing a given string.
### Upper Case: Ensure the correct conversion of a string to uppercase.
### Lower Case: Validate the proper conversion of a string to lowercase.
### Center Elements: Test the centering of elements within a specified width.
### Count String: Confirm the accurate counting of occurrences of a specified word.
### Check End String: Verify the correct identification of string endings.
### Check Start String: Ensure accurate identification of string beginnings.
### Find String: Validate the proper index identification of a specified word.
### Index String: Confirm the correct index identification of a specified word.
### Check Alphabetical: Ensure the accurate detection of alphabetic characters.
### Check Numeric: Validate the correct identification of numeric characters.
### Replace String: Confirm the proper replacement of specified words.
### Split String: Verify the correct splitting of the string into a list.
## List Operations :
### Get Sum: Validate the correct summation of all elements in a list.
### Get Average: Confirm the accurate calculation of the average of list elements.
### Get Min Value: Ensure the proper identification of the minimum value in a list.
### Get Max Value: Validate the correct identification of the maximum value in a list.
### Sort List: Verify the proper sorting of a list in ascending order.
### Reverse List: Confirm the correct reversal of the order of elements in a list.
### Remove Duplicates: Ensure the accurate removal of duplicate elements.
### Element in List: Validate the correct detection of a specified element in a list.
### Count Element: Confirm the accurate counting of occurrences of a specified element.
### Add Element: Ensure the correct addition of a new element to the end of the list.
### Remove Element: Validate the accurate removal of the first occurrence of a specified element.
## Tuple Operations :
### Get Length: Confirm the correct calculation of the length of a tuple.
### Concatenate Tuples: Ensure the accurate concatenation of two tuples.
### Count Element: Validate the proper counting of occurrences of a specified element.
### Element in Tuple: Confirm the correct detection of a specified element in a tuple.
### Convert to Set: Ensure the accurate conversion of a tuple to a set.
## Dictionary Operations :
### Get Keys: Validate the correct retrieval of keys from a dictionary.
### Get Values: Confirm the accurate retrieval of values from a dictionary.
### Key in Dictionary: Ensure the correct detection of a specified key in a dictionary.
### Value in Dictionary: Validate the proper detection of a specified value in a dictionary.
### Add Key-Value Pair: Confirm the accurate addition of a new key-value pair to a dictionary.
### Remove Key-Value Pair: Ensure the correct removal of a key-value pair from a dictionary.
## Set Operations :
### Get Length: Validate the accurate calculation of the length of a set.
### Add Element: Confirm the correct addition of a new element to the set.
### Remove Element: Ensure the accurate removal of an element from the set.
### Element in Set: Validate the proper detection of a specified element in the set.
### Union Sets: Confirm the accurate calculation of the union of two sets.
### Intersection Sets: Validate the proper calculation of the intersection of two sets.
### Difference Sets: Ensure the accurate calculation of the difference between two sets.
## Test Cases:### Comprehensive Coverage: A wide range of test cases has been implemented to cover various scenarios and edge cases.
### Thorough Validation: The test cases thoroughly validate each method to ensure their correctness in diverse situations.
### Robust Testing Framework: The project employs a robust testing framework using the unittest library to streamline test execution and result reporting.## Usage
Developers can use this project as a reference for unit testing their string, list, tuple, dictionary, and set methods. By running the provided test cases, they can ensure the reliability of these fundamental operations in their Python projects.# Project Structure
This project follows a specific structure to organize the code and tests. Here's an overview:
## Code
### Files:
- `__init__.py`: Initialization file for the code directory.
- `calculator.py`: Module containing operations on numeric values.
- `dict.py`: Module containing dictionary-related operations.
- `list.py`: Module containing list-related operations.
- `set.py`: Module containing set-related operations.
- `str.py`: Module containing string-related operations.
- `tuple.py`: Module containing tuple-related operations.## Test
### Files:
- `__init__.py`: Initialization file for the test directory.
- `test_calculator.py`: Unit tests for the `calculator` module.
- `test_dict.py`: Unit tests for the `dict` module.
- `test_list.py`: Unit tests for the `list` module.
- `test_set.py`: Unit tests for the `set` module.
- `test_str.py`: Unit tests for the `str` module.
- `test_tuple.py`: Unit tests for the `tuple` module.- **code**: Contains the main source code files.
- **test**: Contains unit test files.### Dependencies
List any dependencies or requirements needed to run your code.
- Python 3.x
- Any other libraries or packages...