[Checkins] CVS: Products/zzz_generations - generations.py:1.2
tests.py:1.2
Paul Winkler
pw_lists at slinkp.com
Tue Apr 4 17:53:43 EDT 2006
Update of /cvs-repository/Products/zzz_generations
In directory cvs.zope.org:/tmp/cvs-serv2772
Modified Files:
generations.py tests.py
Log Message:
Fixed deprecation warnings and errors when running tests under zope 2.9.
Should still work in zope 2.7.
=== Products/zzz_generations/generations.py 1.1.1.1 => 1.2 ===
--- Products/zzz_generations/generations.py:1.1.1.1 Fri Apr 23 15:23:15 2004
+++ Products/zzz_generations/generations.py Tue Apr 4 17:53:43 2006
@@ -18,12 +18,22 @@
from interfaces import GenerationTooHigh, GenerationTooLow, UnableToEvolve
from interfaces import ISchemaManager
from ZODB.PersistentMapping import PersistentMapping
-import zLOG
import sys
import os
+import logging
+
+# Use the newer transaction API if available. (2.8 or later)
+try:
+ import transaction
+ def get_transaction():
+ return transaction
+except ImportError:
+ pass
generations_key = 'zzz_generations.generations'
+logger = logging.getLogger('zzz_generations')
+
class SchemaManager:
""" Schema manager """
@@ -127,8 +137,7 @@
'Failed to evolve database to generation %d for %s' %
(generation, key) + ' (see error log)')
msgs.append(msg)
- zLOG.LOG('zzz_generations', zLOG.ERROR, msg,
- error=sys.exc_info)
+ logger.error(msg, exc_info=sys.exc_info)
if generation < manager.minimum_generation:
raise UnableToEvolve(generation, key,
=== Products/zzz_generations/tests.py 1.1.1.1 => 1.2 ===
--- Products/zzz_generations/tests.py:1.1.1.1 Fri Apr 23 15:23:15 2004
+++ Products/zzz_generations/tests.py Tue Apr 4 17:53:43 2006
@@ -24,6 +24,7 @@
EVOLVEMINIMUM
from unittest import TestCase, TextTestRunner, makeSuite, TestSuite
from Products.zzz_generations.interfaces import ISchemaManager
+from Products.zzz_generations.generations import get_transaction
def DB():
import ZODB
@@ -95,8 +96,11 @@
self.assertEqual(root.get('app1'), 2)
self.assertEqual(root.get('app2'), None)
+ # Make sure failures get logged.
app1.erron = 4
app1.generation = 7
+ # XXX this puts some distracting errors msgs on stderr, would be nice
+ # if we could suppress that during test runs.
msgs = evolve(self.db)
self.assertEqual(msgs,
['Failed to evolve database to generation 4 for app1'
@@ -133,5 +137,6 @@
if __name__ == '__main__':
runner = TextTestRunner(verbosity=9)
runner.run(test_suite())
+
More information about the Checkins
mailing list