~ubuntu-branches/ubuntu/natty/zope.testing/natty

« back to all changes in this revision

Viewing changes to src/zope/testing/doctest.txt

  • Committer: Bazaar Package Importer
  • Author(s): Brian Sutherland
  • Date: 2009-06-15 05:56:09 UTC
  • Revision ID: james.westby@ubuntu.com-20090615055609-71993ywo73mrvkud
Tags: upstream-3.7.4
ImportĀ upstreamĀ versionĀ 3.7.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
========================
 
2
Additional doctest Tests
 
3
========================
 
4
 
 
5
Most `doctest` module tests are located within the module. This file only
 
6
tests a few additional features not covered by the module tests, so that the
 
7
changes to the `doctest` module -- which is forked from the Python standard
 
8
library -- are minimized.
 
9
 
 
10
Working with Carriage Returns
 
11
-----------------------------
 
12
 
 
13
Due to the way releases are made on different platforms, we sometimes test
 
14
files on a *nix system with Windows file endings. Unfortunately, that leaves
 
15
some of the test files broken:
 
16
 
 
17
  >>> import tempfile
 
18
  >>> fn = tempfile.mktemp()
 
19
  >>> open(fn, 'w').write('Test:\r\n\r\n  >>> x = 1 + 1\r\n\r\nDone.\r\n')
 
20
 
 
21
Let's now run it as a doctest:
 
22
 
 
23
  >>> from zope.testing import doctest
 
24
  >>> doctest.testfile(fn, False)
 
25
  (0, 1)
 
26
 
 
27
It worked. Let's also try the test file suite:
 
28
 
 
29
  >>> import unittest
 
30
  >>> result = unittest.TestResult()
 
31
  >>> doctest.DocFileSuite(fn, module_relative=False).run(result)
 
32
  <unittest.TestResult run=1 errors=0 failures=0>