Commit 1f4c78b7 authored by Jim Fulton's avatar Jim Fulton

Use doctest rather than zope.testing.doctest.

This required using manuel to get the footnote
feature. Unfortunately, manuel imports zope.testing.doctest. :)
Hpefully, this will be fixed soon.

Updated the testhistoricalconnections.py tearDown to clear conflict
resolution class cache. The cache was causing tests to fail when tests
were run multiple times.
parent 539a20f6
......@@ -185,8 +185,8 @@ setup(name="ZODB3",
read_file("README.txt") + "\n\n" +
read_file("src", "CHANGES.txt")),
test_suite="__main__.alltests", # to support "setup.py test"
tests_require = ['zope.testing'],
extras_require = dict(test=['zope.testing']),
tests_require = ['zope.testing', 'manuel'],
extras_require = dict(test=['zope.testing', 'manuel']),
install_requires = [
'transaction',
'zc.lockfile',
......
This diff is collapsed.
......@@ -13,7 +13,7 @@ development continues on a "development" head.
A database can be opened historically ``at`` or ``before`` a given transaction
serial or datetime. Here's a simple example. It should work with any storage
that supports ``loadBefore``.
that supports ``loadBefore``.
We'll begin our example with a fairly standard set up. We
......@@ -29,25 +29,25 @@ We'll begin our example with a fairly standard set up. We
>>> conn = db.open()
>>> import persistent.mapping
>>> conn.root()['first'] = persistent.mapping.PersistentMapping(count=0)
>>> import transaction
>>> transaction.commit()
We wait for some time to pass, record he time, and then make some other changes.
>>> import time
>>> time.sleep(.01)
>>> import datetime
>>> now = datetime.datetime.utcnow()
>>> time.sleep(.01)
>>> root = conn.root()
>>> root['second'] = persistent.mapping.PersistentMapping()
>>> root['first']['count'] += 1
>>> transaction.commit()
Now we will show a historical connection. We'll open one using the ``now``
......@@ -56,14 +56,14 @@ connection, at the mutable head of the database, is different than the
historical state.
>>> transaction1 = transaction.TransactionManager()
>>> historical_conn = db.open(transaction_manager=transaction1, at=now)
>>> sorted(conn.root().keys())
['first', 'second']
>>> conn.root()['first']['count']
1
>>> historical_conn.root().keys()
['first']
>>> historical_conn.root()['first']['count']
......@@ -93,7 +93,7 @@ commit.
>>> historical_serial = historical_conn.root()._p_serial
>>> historical_conn.close()
>>> historical_conn = db.open(transaction_manager=transaction1,
... at=historical_serial)
>>> historical_conn.root().keys()
......@@ -155,7 +155,7 @@ historical connection should be kept.
>>> db.getHistoricalTimeout()
400
All three of these values can be specified in a ZConfig file.
All three of these values can be specified in a ZConfig file.
>>> import ZODB.config
>>> db2 = ZODB.config.databaseFromString('''
......@@ -287,6 +287,12 @@ possible. If historical connections are used for conflict resolution, these
connections will probably be temporary--not saved in a pool--so that the extra
memory usage would also be brief and unlikely to overlap.
.. cleanup
>>> db.close()
>>> db2.close()
.. ......... ..
.. Footnotes ..
.. ......... ..
......
......@@ -11,33 +11,30 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id$
"""
import manuel.doctest
import manuel.footnote
import manuel.capture
import manuel.testing
import unittest
from zope.testing import doctest, module
import ZODB.ConflictResolution
import ZODB.tests.util
import zope.testing.module
def setUp(test):
ZODB.tests.util.setUp(test)
module.setUp(test, 'ConflictResolution_txt')
zope.testing.module.setUp(test, 'ConflictResolution_txt')
def tearDown(test):
test.globs['db'].close()
test.globs['db1'].close()
test.globs['db2'].close()
module.tearDown(test)
zope.testing.module.tearDown(test)
ZODB.tests.util.tearDown(test)
ZODB.ConflictResolution._class_cache.clear()
def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('../ConflictResolution.txt',
setUp=setUp,
tearDown=tearDown,
optionflags=doctest.INTERPRET_FOOTNOTES,
),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
return manuel.testing.TestSuite(
manuel.doctest.Manuel()
+ manuel.footnote.Manuel()
+ manuel.capture.Manuel(),
'../ConflictResolution.txt',
setUp=setUp, tearDown=tearDown,
)
......@@ -11,33 +11,14 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id$
"""
import unittest
from zope.testing import doctest, module
import manuel.doctest
import manuel.footnote
import manuel.testing
import ZODB.tests.util
def setUp(test):
ZODB.tests.util.setUp(test)
module.setUp(test, 'historical_connections_txt')
def tearDown(test):
test.globs['db'].close()
test.globs['db2'].close()
# the DB class masks the module because of __init__ shenanigans
module.tearDown(test)
ZODB.tests.util.tearDown(test)
def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('../historical_connections.txt',
setUp=setUp,
tearDown=tearDown,
optionflags=doctest.INTERPRET_FOOTNOTES,
),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
return manuel.testing.TestSuite(
manuel.doctest.Manuel() + manuel.footnote.Manuel(),
'../historical_connections.txt',
setUp=ZODB.tests.util.setUp, tearDown=ZODB.tests.util.tearDown,
)
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