Running the Tests and the Type Checker

Running the Tests

To install the dependencies needed for the tests, run pipenv install --dev.

Then type:


to run the tests. Add the -rxs flag to see the reason for any x-fails. Add an -s switch for additional logging, especially for the top-level api and example script tests.

To run the tests and generate a code coverage report, type

pytest --cov-report html --cov=protari ; open htmlcov/index.html

Most tests manage their own temporary SQLite database. However, SQLite is lacking some functionality required to get the top rows by absolute value. Tests of this require the URL of an existing database to be passed in the environment variable PROTARI_TEST_DB_URLS. You can pass multiple database URLs in this variable by separating them with spaces, and the tests will run on all the databases. Eg. if you are using Postgres, you can create and point to a database called protari_pytest for use in testing with:

createdb protari_pytest
export PROTARI_TEST_DB_URLS=postgresql:///protari_pytest

If this environment variable is undefined, some tests will x-fail and others will be skipped.

When running these tests on an Oracle database, the test table can sometimes fail to be dropped, and cause problems. In that case, you need to manually drop the test table in sqlplus:

drop table pytest;

Running the Type Checker

You will need python 3.2 or higher.

Then type:

mypy protari/ --ignore-missing-imports --strict-optional --disallow-untyped-defs

Running Both

Once you have installed the requirements, you can run both the tests and the type checker with:

source scripts/

Building this documentation

This documentation is built using Mkdocs.