Testing in owmeta

Preparing for tests

Within the owmeta project directory, owmeta can be installed for development and testing like this:

pip install --editable .

The project database should be populated like:

owm clone https://github.com/openworm/OpenWormData.git

Running tests

Tests should be run via setup.py like:

pytest

you can pass options to pytest like so:

pytest -k ChannelTest

Writing tests

Tests are written using Python’s unittest. In general, a collection of closely related tests should be in one file. For selecting different classes of tests, tests can also be tagged using pytest marks like:

@pytest.mark.tag
class TestClass(unittest.TestCase):
    ...

Currently, marks are used to distinguish between unit-level tests and others which have the inttest mark. All marks are listed in pytest.ini under ‘markers’.

Data Bundle Tests

The tests in DataIntegrityTest.py require that the openworm/owmeta-data bundle is installed. Normally, these will run in the CI environment. If you are doing work that affects what goes in the bundle, you can install new versions of the bundle and run the tests with pytest -m data_bundle.