Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shearichard/python-unittest-sandbox
Illustration of using python unittest
https://github.com/shearichard/python-unittest-sandbox
python-3 python3 testing unittest
Last synced: about 1 month ago
JSON representation
Illustration of using python unittest
- Host: GitHub
- URL: https://github.com/shearichard/python-unittest-sandbox
- Owner: shearichard
- Created: 2021-08-05T00:11:42.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-05T02:54:59.000Z (over 3 years ago)
- Last Synced: 2025-01-09T19:30:59.556Z (about 1 month ago)
- Topics: python-3, python3, testing, unittest
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python Unittest Sandbox
This project is used to demonstrate how the Python [unittest](https://docs.python.org/3/library/unittest.html) module may be used.Tested against Python 3.7 on Ubuntu 20.x
## Environmental Concerns
This project makes use of [Pipenv](https://pipenv.pypa.io/en/latest/) although as it doesn't use any module outside of this project and the python standard library you should be able to make use of it anywhere where python 3.x is found.
## Invoking tests
There are two modules of interest.
### module_framework_illustrator
`module_framework_illustrator`, outputs text to illustrate the order in which different elements of a unittest based module execute. This module is significantly based on a blog post I found but cannot now re-find so I'm sorry I can't credit the author but I am grateful. If you'd like to get in touch I will be happy to provide a credit - just raise an issue on this repository.
This module may be invoked as follows.
```
python -m module_framework_illustrator
```The expected output is
```
(python-unittest-sandbox) rshea@foobar:~/src/python-unittest-sandbox/pyunsa$ python -m module_framework_illustration
setUpModule: __main__ set up AsetUpClass: TestCase1 set up B
setUp: __main__.TestCase1.test_one set up C
__main__.TestCase1.test_one running
tearDown: __main__.TestCase1.test_one tear down C
. setUp: __main__.TestCase1.test_two set up C
__main__.TestCase1.test_two running
tearDown: __main__.TestCase1.test_two tear down C
. tearDownClass: TestCase1 tear down B
setUpModule: __main__ tear down A
----------------------------------------------------------------------
Ran 2 tests in 0.013sOK
```### module
A more real-world illustration of how tests are structured exists in `module.py` and may be invoked as follows.
```
python -m module
```