[Zodb-checkins] CVS: Zope3/src/zope/testing -
doctestunit.py:1.3.16.1
Jim Fulton
jim at zope.com
Fri Sep 12 15:38:06 EDT 2003
Update of /cvs-repository/Zope3/src/zope/testing
In directory cvs.zope.org:/tmp/cvs-serv18088
Modified Files:
Tag: parentgeddon-branch
doctestunit.py
Log Message:
Added the ability to supply setUp and tearDown functions.
=== Zope3/src/zope/testing/doctestunit.py 1.3 => 1.3.16.1 ===
--- Zope3/src/zope/testing/doctestunit.py:1.3 Sun Jun 29 01:07:50 2003
+++ Zope3/src/zope/testing/doctestunit.py Fri Sep 12 15:38:05 2003
@@ -30,7 +30,10 @@
class DocTestTestFailure(Exception):
"""A doctest test failed"""
-def DocTestSuite(module=None):
+def DocTestSuite(module=None,
+ setUp=lambda: None,
+ tearDown=lambda: None,
+ ):
"""Convert doctest tests for a mudule to a unittest test suite
This tests convers each documentation string in a module that
@@ -61,9 +64,16 @@
filename = filename[:-1]
elif filename.endswith(".pyo"):
filename = filename[:-1]
+
+ def testfunc(args=(tester, name, doc, filename, lineno)):
+ setUp()
+ try:
+ _test(*args)
+ finally:
+ tearDown()
+
suite.addTest(unittest.FunctionTestCase(
- lambda args=(tester, name, doc, filename, lineno):
- _test(*args),
+ testfunc,
description = "doctest of "+name
))
More information about the Zodb-checkins
mailing list