1. beno
  2. python-sword2


Clone wiki

python-sword2 / Testsuite

Running the testsuite

There are two main sets of tests:

  • Functional tests (in tests/functional|)
    • These are mainly internal I/O tests, checking that the classes and most of the methods are behaving as expected, and that convenience methods and the like work correctly. These do not need to have access to an external SWORD v2 compliant server and so do not test the HTTP communication methods directly.
    • There is a script within .hooks/precommit.sh which can be added to the mercurial settings to make sure that any commits to the repository must pass these tests. See this for details on how to add this to your local copy.
    • These tests can be run using 'nose' as follows:
nosetests tests/functional
  • HTTP tests (in tests/http)
    • These test the various SWORD2 HTTP requests with an external SWORD v2 server. Currenly, the testsuite requires an instance of the Simple Sword Server running locally to test against.
    • These can be run using 'nose' as follows:
nosetests tests/http

Note that this will attempt to download the latest Simple Sword Server (sss.py) from the sword-app subversion repository. Currently, this script requires python-lxml to be installed in the python environment.


(See here for information about tox)

"tox aims to automate state-of-the-art packaging, testing and deployment of Python software right from your console or CI server, invoking your tools of choice."

Tox is a very useful tool when combined with a Continuous Integration server, such as Jenkins. To use this, simple run 'tox' within the working directory.

Information about configuring Jenkins and Tox to work together

(NB that documentation assumes you are using pytest. If, like this project, you wish to use `nose` to run your testsuite, but want Jenkins integration then:

In tox.ini:

dep = ....
# Remember to add nose to the tox dependancies list.

command=nosetests {TEST LOCATION] --with-xunit

The key addition is `--with-xunit`. This will create a JUnit-compatible log file of the tests in 'nosetests.xml' in the working directory. Point to this in the "Publish JUnit test result report" option.

Currently, due to an awkward lxml dependancy of the sss.py, only the functional tests are run by tox.ini, as the dependancy refuses to build for me...