Skip to content
Patricia Wollstadt edited this page May 16, 2017 · 11 revisions

IDTxl uses the py.test package for testing. Go to their quick start website for instructions on how to write and include unit tests.

Unit Tests

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

$ py.test   # execute py.test 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):

    $ py.test -x            # stop after first failure
    $ py.test --maxfail=2   # stop after two failures
    $ py.test 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 py.test --cov-report html --cov idtxl creates html output in a subfolder htmlcov.)

System Tests

The test folder also contains system tests in files systemtest_*.py, which are tests of whole algorithms or analyses.

Bidirectionally Coupled Lorenz-Systems

MuTE AR-Network

Clone this wiki locally