A simple code quality and unit testing skeleton using Coverage, Flake8, and the built in Python unittest module.
- Clone this repository and
cdinto the cloned directory. - Choose either one of these options:
- Execute
./config/init.shto install everything needed as well as some additional helpers. - Run these commands to install everything manually:
python -m venv venvsource venv/bin/activatepip install --upgrade pippip install -r requirements.txtdeactivate
- Execute
- From the root of the cloned directory, execute:
./test/test.sh, which should output:
Running Unit Tests.
..
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
Name Stmts Miss Cover Missing
----------------------------------------------------
skeleton/__init__.py 0 0 100%
skeleton/addition.py 4 0 100%
----------------------------------------------------
TOTAL 4 0 100%
Success: Tests Passed and Coverage is 100%.
Running Code Quality Tests (flake8).
Success: No code quality issues detected.
- You will need to update the
MODULE_DIRvariable in thetest/test.shfile to point to your correct module directory instead ofskeleton.- If your project has multiple modules, you will need to update the
test/test.shfile accordingly.
- If your project has multiple modules, you will need to update the
- If you expect/desire less than 100% code coverage for your project, update the
MINIMUM_COVERAGEvariable intest/test.shaccordingly. - The
test/directory can (should) be an exact mirror of the structure of your module's directory, as shown in theskeletonexample module.- This probably goes without saying, but the one exception is the existence of the additional
test.shandtest.pyfiles in thetest/directory.
- This probably goes without saying, but the one exception is the existence of the additional
- Ensure you include the expected
__init__.pyfiles in all nested test directories, to enable the test runner to discover all your tests.