Skip to content

Contribution to pyplis and testing

Solvejg Dinger edited this page Feb 11, 2019 · 2 revisions

Whether you just want to check your installation or want to contribute with new developments, here you can find a couple of testing options. Also note, that any pull request needs to pass the tests.

Pytest tests

Pyplis contains a couple of tests which will be extended in the future. They are written in the pytest framework and you can contribute by adding more test cases. All test scripts can be found inside the test folder.

In order to run the test suit, you have to have pyplis installed from source (from github using python setup.py install as described in the README.rst). The tests can be run manually from the root directory (where the setup.py file lies) in the command line (not Python console) using $ python -m pytest

If any test fails, please raise an issue and we can look into it (provided that you did not change the source code).

Example scripts

In order to run the Etna example scripts, you have to download the Etna test dataset (about 2.7 GB). You can download the testdata automatically into a specified folder <desired_location>

  >>> import pyplis
  >>> pyplis.inout.download_test_data(<desired_location>)

If you leave <desired_location> empty, the data will be downloaded into the my_pyplis folder, that is automatically created on installation in your user home directory.

The scripts can be found in the scripts folder of the repo. They can be run automatically from the console line using

python RUN_INTRO_SCRIPTS.py --test 1
python RUN_EXAMPLE_SCRIPTS.py --test 1

The command line option --test 1 indicates that they should be run in test mode. This mode can be also activated permanently in SETTINGS.py.

Tox

tox is a generic virtualenv management and test command line tool you can use for:

  • checking your package installs correctly with different Python versions and interpreters
  • running your tests in each of the environments, configuring your test tool of choice
  • acting as a frontend to Continuous Integration servers, greatly reducing boilerplate and merging CI and shell

tox automaticaly creates virtual environments for which it installs all packages specified in requirements.txt. tox itself can be installed via $ pip install tox. The test environments have to be specified in tox.ini, in that case you can run $ tox in the pyplis root directory from the console. It will run all tests and example scripts on multi-versions of python and notify you if any errors occure.

Note: tox was not designed to work with conda environments. The above simple code will not work, but there are workarounds avaialable. To be continued.

Clone this wiki locally