Documente Academic
Documente Profesional
Documente Cultură
Docutils_ Testing
===================
:Authors: Lea Wiemann <LeWiemann@gmail.com>;
David Goodger <goodger@python.org>
:Revision: $Revision: 6159 $
:Date: $Date: 2009-10-09 03:17:59 -0400 (Fri, 09 Oct 2009) $
:Copyright: This document has been placed in the public domain.
.. _Docutils: http://docutils.sourceforge.net/
.. contents::
When adding new functionality (or fixing bugs), be sure to add test
cases to the test suite. Practise test-first programming; it's fun,
it's addictive, and it works!
This document describes how to run the Docutils test suite, how the
tests are organized and how to add new tests or modify existing tests.
Running the Test Suite
======================
Before checking in any changes, run the entire Docutils test suite to
be sure that you haven't broken anything. From a shell::
cd docutils/test
./alltests.py
Python Versions
===============
The Docutils 0.6 release supports Python 2.3 or later. Therefore, you should
actually have Pythons 2.3, as well as the latest Python (2.6 at the time
of this writing) installed and always run the tests on all of them. (A good
way to do that is to always run the test suite through a short script that
runs ``alltests.py`` under each version of Python.) If you can't afford
installing 3 or more Python versions, the edge cases (2.3, and 2.6) should
cover most of it.
Good resources covering the differences between Python versions:
*
*
*
*
*
__
__
__
__
__
unittest.main()
For more details on how to write tests, please refer to the
documentation of the ``unittest`` module.
.. _functional:
Functional Tests
================
The directory ``test/functional/`` contains data for functional tests.
Performing functional testing means testing the Docutils system as a
whole (i.e. blackbox testing).
Directory Structure
------------------+ ``functional/`` The main data directory.
+ ``input/`` The input files.
- ``some_test.txt``, for example.
+ ``output/`` The actual output.
- ``some_test.html``, for example.
+ ``expected/`` The expected output.
- ``some_test.html``, for example.
+ ``tests/`` The config files for processing the input files.
- ``some_test.py``, for example.
- ``_default.py``, the `default configuration file`_.
The Testing Process
------------------When running ``test_functional.py``, all config files in
``functional/tests/`` are processed. (Config files whose names begin
with an underscore are ignored.) The current working directory is
always Docutils' main test directory (``test/``).
For example, ``functional/tests/some_test.py`` could read like this::
# Source and destination file names.
test_source = "some_test.txt"
test_destination = "some_test.html"
# Keyword parameters passed to publish_file.
reader_name = "standalone"
parser_name = "rst"
writer_name = "html"
settings_overrides['output-encoding'] = 'utf-8'