summaryrefslogtreecommitdiffstats
path: root/Doc/library/unittest.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-05-29 21:20:41 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-05-29 21:20:41 (GMT)
commitb09f19836208148358d408c06ffd66035cdaa69e (patch)
tree7eb1d04d07209f727696099bc9d2c6a7d3d56b04 /Doc/library/unittest.rst
parentb4a81c838a5b709fdd8f591e7ce3b69da1fe91a3 (diff)
downloadcpython-b09f19836208148358d408c06ffd66035cdaa69e.zip
cpython-b09f19836208148358d408c06ffd66035cdaa69e.tar.gz
cpython-b09f19836208148358d408c06ffd66035cdaa69e.tar.bz2
Move the basic examples section back to the beginning.
Diffstat (limited to 'Doc/library/unittest.rst')
-rw-r--r--Doc/library/unittest.rst130
1 files changed, 67 insertions, 63 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index bc26f05..ff096a7 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -91,70 +91,7 @@ need to derive from a specific class.
Tools for creating mock test objects (objects simulating external resources).
-.. _unittest-command-line-interface:
-
-Command Line Interface
-----------------------
-
-The unittest module can be used from the command line to run tests from
-modules, classes or even individual test methods::
-
- python -m unittest test_module1 test_module2
- python -m unittest test_module.TestClass
- python -m unittest test_module.TestClass.test_method
-
-You can pass in a list with any combination of module names, and fully
-qualified class or method names.
-
-You can run tests with more detail (higher verbosity) by passing in the -v flag::
- python-m unittest -v test_module
-
-For a list of all the command line options::
-
- python -m unittest -h
-
-.. versionchanged:: 2.7
- In earlier versions it was only possible to run individual test methods and
- not modules or classes.
-
-The command line can also be used for test discovery, for running all of the
-tests in a project or just a subset.
-
-
-.. _unittest-test-discovery:
-
-Test Discovery
---------------
-
-.. versionadded:: 2.7
-
-unittest supports simple test discovery. For a project's tests to be
-compatible with test discovery they must all be importable from the top level
-directory of the project; i.e. they must all be in Python packages.
-
-Test discovery is implemented in :meth:`TestLoader.discover`, but can also be
-used from the command line. The basic command line usage is::
-
- cd project_directory
- python -m unittest discover
-
-The ``discover`` sub-command has the following options:
-
- -v, --verbose Verbose output
- -s directory Directory to start discovery ('.' default)
- -p pattern Pattern to match test files ('test*.py' default)
- -t directory Top level directory of project (default to
- start directory)
-
-The -s, -p, & -t options can be passsed in as positional arguments. The
-following two command lines are equivalent::
-
- python -m unittest -s project_directory -p '*_test.py'
- python -m unittest project_directory '*_test.py'
-
-Test modules and packages can customize test loading and discovery by through
-the `load_tests protocol`_.
.. _unittest-minimal-example:
@@ -243,6 +180,73 @@ The above examples show the most commonly used :mod:`unittest` features which
are sufficient to meet many everyday testing needs. The remainder of the
documentation explores the full feature set from first principles.
+
+.. _unittest-command-line-interface:
+
+Command Line Interface
+----------------------
+
+The unittest module can be used from the command line to run tests from
+modules, classes or even individual test methods::
+
+ python -m unittest test_module1 test_module2
+ python -m unittest test_module.TestClass
+ python -m unittest test_module.TestClass.test_method
+
+You can pass in a list with any combination of module names, and fully
+qualified class or method names.
+
+You can run tests with more detail (higher verbosity) by passing in the -v flag::
+
+ python-m unittest -v test_module
+
+For a list of all the command line options::
+
+ python -m unittest -h
+
+.. versionchanged:: 2.7
+ In earlier versions it was only possible to run individual test methods and
+ not modules or classes.
+
+The command line can also be used for test discovery, for running all of the
+tests in a project or just a subset.
+
+
+.. _unittest-test-discovery:
+
+Test Discovery
+--------------
+
+.. versionadded:: 2.7
+
+Unittest supports simple test discovery. For a project's tests to be
+compatible with test discovery they must all be importable from the top level
+directory of the project (in other words, they must all be in Python packages).
+
+Test discovery is implemented in :meth:`TestLoader.discover`, but can also be
+used from the command line. The basic command line usage is::
+
+ cd project_directory
+ python -m unittest discover
+
+The ``discover`` sub-command has the following options:
+
+ -v, --verbose Verbose output
+ -s directory Directory to start discovery ('.' default)
+ -p pattern Pattern to match test files ('test*.py' default)
+ -t directory Top level directory of project (default to
+ start directory)
+
+The -s, -p, & -t options can be passsed in as positional arguments. The
+following two command lines are equivalent::
+
+ python -m unittest -s project_directory -p '*_test.py'
+ python -m unittest project_directory '*_test.py'
+
+Test modules and packages can customize test loading and discovery by through
+the `load_tests protocol`_.
+
+
.. _organizing-tests:
Organizing test code