========================
Additional doctest Tests
========================

Most `doctest` module tests are located within the module. This file only
tests a few additional features not covered by the module tests, so that the
changes to the `doctest` module -- which is forked from the Python standard
library -- are minimized.

Working with Carriage Returns
-----------------------------

Due to the way releases are made on different platforms, we sometimes test
files on a *nix system with Windows file endings. Unfortunately, that leaves
some of the test files broken:

  >>> import tempfile
  >>> fn = tempfile.mktemp()
  >>> open(fn, 'w').write('Test:\r\n\r\n  >>> x = 1 + 1\r\n\r\nDone.\r\n')

Let's now run it as a doctest:

  >>> from zope.testing import doctest
  >>> doctest.testfile(fn, False)
  (0, 1)

It worked. Let's also try the test file suite:

  >>> import unittest
  >>> result = unittest.TestResult()
  >>> doctest.DocFileSuite(fn, module_relative=False).run(result) #doctest: +ELLIPSIS
  <...TestResult run=1 errors=0 failures=0>

Regression tests
----------------

This section is about regression tests of ``zope.testing`` itself.

  >>> from zope.testing.doctest import *

LP #69988 and #144569 both assert that doctests fail when rendering
non-ASCII output with a UnicodeDecodeError.  However, this does not appear
to be so:

  >>> print u'abc'
  abc

  >>> print u'\xe9'.encode('utf-8')
  é

Tests for LP #561568:

  >>> v = u'foo\xe9bar'
  >>> v # doctest: +ELLIPSIS
  u'foo...bar'

  >>> v.encode('utf-8') # doctest: +ELLIPSIS
  'foo...bar'
