Unitary tests#
Develop unitary tests to validated all functions and methods by using the pytest framework.
Python package organisation#
p400-xxx/
p400xxx/
tests/
__init__.py
conftest.py
test_100_myclass1.py
test_200_myclass2.py
File naming convention#
Naming convention for test files is given in the table below.
Values between {}
are mandatory while those between []
are optional.
grammar |
definition |
exemple |
---|---|---|
test_{section id}_{class name}.csv |
unique file name |
|
{section id} |
identifier of the section |
|
{class name} |
name of the class in lowercase |
|
Test function naming convention#
Naming convention for test function is given in the table below.
Values between {}
are mandatory while those between []
are optional.
grammar |
definition |
exemple |
---|---|---|
test_{class name}_{method}_{test id}.csv |
unique name |
|
{class name} |
name of the class in lower case |
|
{method} |
name of the method in lowercase |
|
{test id} |
unique 3 digit number to identify the test. the MSB is the one of the |
|
Import a class or function in a test module#
from p400xxx.mymodule import myclass, myfunction
Run the test suite#
(venv) $ cd p400-xxx/tests
(venv) $ pytest --collect-only -q # (list of availble test)
(venv) $ pytest -k test_id # (run one test identified by its number)
(venv) $ pytest # (run all tests)