Commit 102cc2ea authored by Tim Peters's avatar Tim Peters

Until we can rely on Python 2.4, take DocFileSuite from

zope.testing instead of rolling our own.
parent 47126e35
...@@ -19,36 +19,13 @@ import unittest ...@@ -19,36 +19,13 @@ import unittest
import persistent.tests import persistent.tests
from persistent import Persistent from persistent import Persistent
from zope.testing.doctestunit import DocFileSuite
class P(Persistent): class P(Persistent):
def __init__(self): def __init__(self):
self.x = 0 self.x = 0
def inc(self): def inc(self):
self.x += 1 self.x += 1
try:
DocFileSuite = doctest.DocFileSuite # >= Python 2.4.0a2
except AttributeError:
# <= Python 2.4.0a1
def DocFileSuite(path, globs=None):
# It's not entirely obvious how to connection this single string
# with unittest. For now, re-use the _utest() function that comes
# standard with doctest in Python 2.3. One problem is that the
# error indicator doesn't point to the line of the doctest file
# that failed.
path = os.path.join(persistent.tests.__path__[0], path)
source = open(path).read()
if globs is None:
globs = sys._getframe(1).f_globals
t = doctest.Tester(globs=globs)
def runit():
doctest._utest(t, path, source, path, 0)
f = unittest.FunctionTestCase(runit,
description="doctest from %s" % path)
suite = unittest.TestSuite()
suite.addTest(f)
return suite
def test_suite(): def test_suite():
return DocFileSuite("persistent.txt", globs={"P": P}) return DocFileSuite("persistent.txt", globs={"P": P})
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment