.. _testing:

Testing 
=======

The source code distribution of the relayr Python library contains a testsuite
that can be run after downloading the full code archive. It is not installed
together with the Python package itself, but needs to be run from the unarchived
code distribution. This has been tesed on Linux and OS X.

The test suite is located inside the ``tests`` subdirectory
and can be run using PyTest_ which, unlike the ``unittest`` framework,
does not require writing boilerplate code. This allows, among other things,
for reusing single test snippets more easily outside of the test suite.

To run the tests you don't even need to have PyTest_ installed since the
archive contains a file named ``runtests.py`` which is essentially a minimized
version of PyTest_ itself (generated by the respective ``py.test`` tool).

Running the full test suite from the main directory of the unarchived code
distribution is as simple as this:

.. code-block:: console

    $ python runtests.py tests

If you have PyTest_ installed (``pip install pytest`` will do) you can
ommit the ``runtests.py`` file:

.. code-block:: console

    $ py.test tests

In both cases the output should be something like this, when everything runs
correctly (the ``s`` indicates a skipped test, here because of platform limitations):

.. code-block:: console

    =========================== test session starts ============================
    platform darwin -- Python 2.7.6 -- py-1.4.26 -- pytest-2.6.4
    collected 41 items

    tests/test_anonymous.py ..........
    tests/test_bluetooth.py sss
    tests/test_config.py .
    tests/test_data_access.py .
    tests/test_registered.py .........................

    ================== 38 passed, 3 skipped in 80.59 seconds ===================

Naturally, you can add more verbosity, run selected test modules or methods
if desired, run tests for different Python versions simultaneously, and much more.


.. _PyTest: http://pytest.org/
