/python-unittest

A Brief Guide to Python Testing

Primary LanguagePython

image

A short practical guide to testing Python (unittest)

A little guide to help you test your Python code with framework unittest.

Excution

venv:

python3 -m venv .venv && . .venv/bin/activate

Install:

In both environments you will need to install it only once.

pip install mock
pip install requests
pip install coverage
pip install SQLAlchemy

Running Tests:

python -m unittest discover -v
python -m unittest discover example1/
python -m unittest discover -p 'test_*.py'

Coverage:

coverage run -m unittest discover -v
coverage report -m
coverage html

coverage run -m unittest discover && coverage report -m && coverage html

Articles