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