-
Notifications
You must be signed in to change notification settings - Fork 76
Testing
IDTxl uses the pytest
package for testing.
This is the folder structure of the IDTxl package:
IDTxl/
setup.py # your setuptools Python package metadata
idtxl/ # actual code
__init__.py
multivariate_te.py
...
test/ # unit and system tests
test_multivariate_te.py
...
Go to the test
folder and call
$ pytest # execute pytest with Python 3
This starts the py.test module, which will automatically collect all
test_*.py
or *_test.py
files and execute them (see
here for
py.test's test detection rules).
Before this works, you have to make sure IDTxl is importable, i.e., it has to
be installed system-wide. This can be done by navigating into the IDTxl folder
(where setup.py
is) and running
$ pip3 install -e . # install package using setup.py in editable mode
This will install IDTxl in 'editable' or development mode, which means pip creates a soft link in Python's site-packages to the current IDTxl location (see here for details). This way you can keep making changes in the Package without the need to reinstall it after each change.
Some more ways to invoke unit tests with py.test (go here for a full documentation):
$ pytest -x # stop after first failure
$ pytest --maxfail=2 # stop after two failures
$ pytest test_mod.py # run tests in given module
If pytest-cov
is installed a report on code coverage can be created by calling
py.test --cov idtxl
inside the test folder. (Running pytest --cov-report html --cov idtxl
creates html output in a subfolder htmlcov
.)
The test
folder also contains system tests in files systemtest_*.py
, which are tests of whole algorithms or analyses.