jython-docs/devguide / runtests.rst

Full commit

Running & Writing Tests


This document assumes you are working from an :ref:`in-development <indevbranch>` checkout of Jython. If you are not then some things presented here may not work as they may depend on new features not available in earlier versions of Jython.


The shortest, simplest way of running the test suite is the following command from the root directory of your checkout:

ant regrtest


Writing tests for Python is much like writing tests for your own code. Tests need to be thorough, fast, isolated, consistently repeatable, and as simple as possible. We try to have tests both for normal behaviour and for error conditions. Tests live in the Lib/test directory, where every file that includes tests has a test_ prefix.

One difference with ordinary testing is that you are encouraged to rely on the :py:mod:`` module. It contains various helpers that are tailored to Python's test suite and help smooth out common problems such as platform differences, resource consumption and cleanup, or warnings management. That module is not suitable for use outside of the standard library.

When you are adding tests to an existing test file, it is also recommended that you study the other tests in that file; it will teach you which precautions you have to take to make your tests robust and portable.