[Zodb-checkins] CVS: Zope3/src/zope/testing - doc.py:1.1

Jim Fulton jim at zope.com
Fri Apr 18 18:42:46 EDT 2003


Update of /cvs-repository/Zope3/src/zope/testing
In directory cvs.zope.org:/tmp/cvs-serv4959

Added Files:
	doc.py 
Log Message:
Added quick and dirty helper function for running doctest tests from
unit tests.


=== Added File Zope3/src/zope/testing/doc.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Unit test helper that uses doctest

$Id: doc.py,v 1.1 2003/04/18 21:42:45 jim Exp $
"""

import sys
from StringIO import StringIO
from doctest import testmod

def doctest(testcase, module):

    old = sys.stdout
    new = StringIO()
    try:
        sys.stdout = new
        failures, tries = testmod(module, isprivate=lambda *a: False)
    finally:
        sys.stdout = old

    testcase.failIf(failures, new.getvalue())




More information about the Zodb-checkins mailing list