Commit b427bb74 authored by Jim Fulton's avatar Jim Fulton

Use newer doctest

parent 0abbea6b
...@@ -495,7 +495,7 @@ def test_zsp_gets_right_roles_for_methods(): ...@@ -495,7 +495,7 @@ def test_zsp_gets_right_roles_for_methods():
""" """
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
...@@ -1527,7 +1527,7 @@ def showaq(m_self, indent=''): ...@@ -1527,7 +1527,7 @@ def showaq(m_self, indent=''):
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
......
...@@ -66,7 +66,7 @@ def test_wrapper_support(): ...@@ -66,7 +66,7 @@ def test_wrapper_support():
""" """
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
from ExtensionClass import Base from ExtensionClass import Base
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
......
...@@ -737,7 +737,7 @@ def test___of___w_metaclass_instance(): ...@@ -737,7 +737,7 @@ def test___of___w_metaclass_instance():
""" """
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
import unittest import unittest
def test_suite(): def test_suite():
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
$Id$ $Id$
""" """
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
def test_xxx(): def test_xxx():
""" """
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
$Id$ $Id$
""" """
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
$Id$ $Id$
""" """
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
$Id$ $Id$
""" """
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
import pickle import pickle
from Persistence import Persistent from Persistence import Persistent
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
$Id$ $Id$
""" """
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
from Persistence import PersistentMapping from Persistence import PersistentMapping
def test_basic_functionality(): def test_basic_functionality():
......
...@@ -39,7 +39,7 @@ def test_RecordPickling(): ...@@ -39,7 +39,7 @@ def test_RecordPickling():
""" """
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
......
...@@ -57,7 +57,7 @@ $Id: tests.py,v 1.2 2003/11/28 16:46:39 jim Exp $ ...@@ -57,7 +57,7 @@ $Id: tests.py,v 1.2 2003/11/28 16:46:39 jim Exp $
import ThreadLock, threading, time import ThreadLock, threading, time
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
......
...@@ -405,7 +405,7 @@ class Rollback(object): ...@@ -405,7 +405,7 @@ class Rollback(object):
def test_suite(): def test_suite():
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
return DocTestSuite() return DocTestSuite()
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -20,7 +20,7 @@ import sys ...@@ -20,7 +20,7 @@ import sys
import unittest import unittest
import persistent import persistent
import transaction import transaction
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
from ZODB.tests.util import DB from ZODB.tests.util import DB
def test_integration(): def test_integration():
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Unit tests for the Connection class.""" """Unit tests for the Connection class."""
import doctest from zope.testing import doctest
import unittest import unittest
import warnings import warnings
......
...@@ -350,7 +350,7 @@ def testTimeTravelOnOpen(): ...@@ -350,7 +350,7 @@ def testTimeTravelOnOpen():
""" """
def test_suite(): def test_suite():
import doctest from zope.testing import doctest
suite = unittest.TestSuite() suite = unittest.TestSuite()
for klass in [FileStorageTests, Corruption.FileStorageCorruptTests, for klass in [FileStorageTests, Corruption.FileStorageCorruptTests,
......
...@@ -118,7 +118,7 @@ class SerializerTestCase(unittest.TestCase): ...@@ -118,7 +118,7 @@ class SerializerTestCase(unittest.TestCase):
def test_suite(): def test_suite():
import doctest from zope.testing import doctest
suite = unittest.makeSuite(SerializerTestCase) suite = unittest.makeSuite(SerializerTestCase)
suite.addTest(doctest.DocTestSuite("ZODB.serialize")) suite.addTest(doctest.DocTestSuite("ZODB.serialize"))
return suite return suite
...@@ -132,7 +132,7 @@ database state as of the last sub-transaction commit. There is ...@@ -132,7 +132,7 @@ database state as of the last sub-transaction commit. There is
""" """
import doctest from zope.testing import doctest
def test_suite(): def test_suite():
return doctest.DocTestSuite() return doctest.DocTestSuite()
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Test behavior of Connection plus cPickleCache.""" """Test behavior of Connection plus cPickleCache."""
import doctest from zope.testing import doctest
from persistent import Persistent from persistent import Persistent
import transaction import transaction
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
$Id$ $Id$
""" """
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
from transaction._transaction import DataManagerAdapter from transaction._transaction import DataManagerAdapter
from ZODB.tests.sampledm import DataManager from ZODB.tests.sampledm import DataManager
......
...@@ -358,7 +358,7 @@ clearing the Connection's local transaction. ...@@ -358,7 +358,7 @@ clearing the Connection's local transaction.
""" """
import doctest from zope.testing import doctest
def test_suite(): def test_suite():
return doctest.DocTestSuite() return doctest.DocTestSuite()
...@@ -267,7 +267,7 @@ def testPublisher(): ...@@ -267,7 +267,7 @@ def testPublisher():
pass pass
import doctest from zope.testing import doctest
def test_suite(): def test_suite():
return doctest.DocTestSuite() return doctest.DocTestSuite()
...@@ -40,7 +40,7 @@ def test_delitem(): ...@@ -40,7 +40,7 @@ def test_delitem():
""" """
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
import unittest import unittest
def test_suite(): def test_suite():
......
...@@ -398,5 +398,5 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent): ...@@ -398,5 +398,5 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
def test_suite(): def test_suite():
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
return DocTestSuite() return DocTestSuite()
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE. # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
import doctest from zope.testing import doctest
import os import os
import sys import sys
import unittest import unittest
...@@ -25,30 +25,5 @@ class P(Persistent): ...@@ -25,30 +25,5 @@ class P(Persistent):
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 doctest.DocFileSuite("persistent.txt", globs={"P": P})
...@@ -276,7 +276,7 @@ def test_pickling_w_slots_w_empty_dict(): ...@@ -276,7 +276,7 @@ def test_pickling_w_slots_w_empty_dict():
""" """
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
import unittest import unittest
def test_suite(): def test_suite():
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
$Id$ $Id$
""" """
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
def test_suite(): def test_suite():
return DocTestSuite('persistent.wref') return DocTestSuite('persistent.wref')
......
...@@ -405,7 +405,7 @@ class Rollback(object): ...@@ -405,7 +405,7 @@ class Rollback(object):
def test_suite(): def test_suite():
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
return DocTestSuite() return DocTestSuite()
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -148,7 +148,7 @@ class TestConnection: ...@@ -148,7 +148,7 @@ class TestConnection:
obj.abort() obj.abort()
self.aborted.append(obj) self.aborted.append(obj)
import doctest from zope.testing import doctest
def test_suite(): def test_suite():
return doctest.DocTestSuite() return doctest.DocTestSuite()
...@@ -636,7 +636,7 @@ def test_join(): ...@@ -636,7 +636,7 @@ def test_join():
""" """
def test_suite(): def test_suite():
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
return unittest.TestSuite(( return unittest.TestSuite((
DocTestSuite(), DocTestSuite(),
unittest.makeSuite(TransactionTests), unittest.makeSuite(TransactionTests),
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
$Id$ $Id$
""" """
import unittest import unittest
from doctest import DocTestSuite from zope.testing.doctest import DocTestSuite
def test_suite(): def test_suite():
return DocTestSuite('transaction.util') return DocTestSuite('transaction.util')
......
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