root / PyCon07 / material / doctest.txt

Revision 63:e6fd368e8f33, 492 bytes (checked in by Tarek Ziad?? <tarek@…>, 18 months ago)

fixed test

Line 
1===============
2doctest example
3===============
4
5You can create documents with code examples. They look like prompt extracts.
6Python provides a module called `doctest` that knows how to extract code
7examples out of a text file, to execute them.
8
9For example, this piece of code::
10
11    >>> 1 + 1
12    2
13
14Can be interpreted by `doctest`, to ensure that the result is 2.
15
16When an example fails, `doctest` raises an assertion error, like
17a classical unit test would do::
18
19    >>> 1 + 1
20    2
21
22
23
Note: See TracBrowser for help on using the browser.