Skip to content

A simple code quality and unit testing skeleton using Coverage, Flake8, and the built in Python `unittest` module.

Notifications You must be signed in to change notification settings

hickeroar/python-test-skeleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Test Skeleton

A simple code quality and unit testing skeleton using Coverage, Flake8, and the built in Python unittest module.

Dependencies

Installation/Initialization

  • Clone this repository and cd into the cloned directory.
  • Choose either one of these options:
    • Execute ./config/init.sh to install everything needed as well as some additional helpers.
    • Run these commands to install everything manually:
      • python -m venv venv
      • source venv/bin/activate
      • pip install --upgrade pip
      • pip install -r requirements.txt
      • deactivate

Usage

  • 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.

Using with your own project

  • You will need to update the MODULE_DIR variable in the test/test.sh file to point to your correct module directory instead of skeleton.
    • If your project has multiple modules, you will need to update the test/test.sh file accordingly.
  • If you expect/desire less than 100% code coverage for your project, update the MINIMUM_COVERAGE variable in test/test.sh accordingly.
  • The test/ directory can (should) be an exact mirror of the structure of your module's directory, as shown in the skeleton example module.
    • This probably goes without saying, but the one exception is the existence of the additional test.sh and test.py files in the test/ directory.
  • Ensure you include the expected __init__.py files in all nested test directories, to enable the test runner to discover all your tests.

About

A simple code quality and unit testing skeleton using Coverage, Flake8, and the built in Python `unittest` module.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages