[py-svn] r6883 - py/dist/doc
hpk at codespeak.net
hpk at codespeak.net
Sun Oct 10 14:35:53 CEST 2004
Author: hpk
Date: Sun Oct 10 14:35:52 2004
New Revision: 6883
Modified:
py/dist/doc/test.txt
Log:
some more work on the test text.
Modified: py/dist/doc/test.txt
==============================================================================
--- py/dist/doc/test.txt (original)
+++ py/dist/doc/test.txt Sun Oct 10 14:35:52 2004
@@ -5,8 +5,6 @@
.. contents::
.. sectnum::
-This is very much a draft version.
-
starting point: ``py.test`` command line tool
=============================================
@@ -33,8 +31,55 @@
to see the list of options.
-Managing test data across test modules, classes and methods
-===========================================================
+
+Basic features for writing tests
+================================
+
+assert with the ``assert statement``
+------------------------------------
+
+writing assertions is very simple and this
+is one of its most noticeable features:
+
+ You can simply use the ``assert`` statement.
+
+For example you can write:
+
+ assert hasattr(x, 'something')
+
+and in case this fails the ``test reporter`` will provide
+you with a very helpful analysis and a clean traceback.
+
+Please note that in order to display helpful analysis
+of a failing ``assert`` expression some magic takes
+place behind the scenes. For now, you only need to
+know that if something looks strange or you suspect
+a bug in that behind-the-scenes-magic you may turn
+of the magic by providing the ``--nomagic`` option.
+
+how to write assertions about execptions
+----------------------------------------
+
+In order to write assertions about exceptions, you use
+one of two forms::
+
+ py.test.assert_raises(Exception, func, *args, **kwargs)
+ py.test.assert_raises(Exception, "func(*args, **kwargs)")
+
+both of which execute the given function with args and kwargs
+and asserts that the given ``Exception`` is raised. Again,
+in case of the possible failures (*no exception** or *wrong
+exception*) the reporter provides you with helpful output.
+
+debug with the ``print statement``
+----------------------------------
+
+By default, the py lib catches stdout/stderr while executing
+tests. This output is only displayed when the test fails,
+otherwise you will not see it.
+
+Managing test state across test modules, classes and methods
+------------------------------------------------------------
Often you want to create some test files, db-connections or
other state in order to run tests in a certain environment.
@@ -83,40 +128,6 @@
-how to write assertions
------------------------
-
-writing assertions is very simple and this
-is one of its most noticeable features:
-
- You can simply use the ``assert`` statement.
-
-For example you can write:
-
- assert hasattr(x, 'something')
-
-and in case this fails the ``test reporter`` will provide
-you with a very helpful analysis and a clean traceback.
-
-Please note that in order to display helpful analysis
-of a failing ``assert`` expression some magic takes
-place behind the scenes. For now, you only need to
-know that if something looks strange or you suspect
-a bug in that behind-the-scenes-magic you may turn
-of the magic by providing the ``--nomagic`` option.
-
-In order to write assertions regarding exceptions, you use
-one of two forms::
-
- py.test.assert_raises(Exception, func, *args, **kwargs)
- py.test.assert_raises(Exception, "func(*args, **kwargs)")
-
-both of which execute the given function with args and kwargs
-and asserts that the given ``Exception`` is raised. Again,
-in case of the two possible failures (no exception or wrong
-exception) the reporter provides you with helpful output.
-
-
The three components of ``py.test``
===================================
More information about the pytest-commit
mailing list