Next: , Previous: Writing Tests, Up: Writing Tests



4.1 Writing New Tests

New tests can be added to WAchecker by writing Python files and placing them into one of the directories defined in the test_directories variable in config.py. Because tests must be loaded before test sets are defined, the following rule is defined to distinguish between test source files and test set source files: Python files whose names start with lowercase letters contain tests, while Python files whose names start with capital letters contain test sets.

Each test is a subclass of the wachecker.test.Test class. The following class attributes should be redefined in each new test class:

_name
“Human readable” test name.
_description
Short description of the test.
_url
URL (as a string) containing information about accessibility issues related to the test, or an empty string.
_state
Implementation state of the test. It must be one of the wachecker.test.Implementation_State constants, usually wachecker.test.Implementation_State.COMPLETE.
_version
Version number of the test as an integer. It should be increased each time the test implementation is modified in such a way that it can produce results different from the previous version.

The test functionality is implemented in the _run (self, document) method (don't redefine the public run method!). The method must return a list of wachecker.test.Issue instances (for more information about them, see The Issue Class).

Note the module wachecker.test contains several customized wachecker.test.Test subclasses which you can use for writing tests. Often you can use them and redefine their specialized methods instead of writing your own _run methods. Look into source code of tests for examples.

All loaded test are placed into wachecker.test module.