[Zodb-checkins] SVN: ZODB/branches/achapman-conflicterror-unicode/src/ZODB/ fix for ConflictError printing
Alex Chapman
achapman at zope.com
Fri Oct 16 17:11:39 EDT 2009
Log message for revision 105112:
fix for ConflictError printing
Changed:
U ZODB/branches/achapman-conflicterror-unicode/src/ZODB/POSException.py
A ZODB/branches/achapman-conflicterror-unicode/src/ZODB/tests/conflict_str.txt
U ZODB/branches/achapman-conflicterror-unicode/src/ZODB/tests/testconflictresolution.py
-=-
Modified: ZODB/branches/achapman-conflicterror-unicode/src/ZODB/POSException.py
===================================================================
--- ZODB/branches/achapman-conflicterror-unicode/src/ZODB/POSException.py 2009-10-16 21:09:23 UTC (rev 105111)
+++ ZODB/branches/achapman-conflicterror-unicode/src/ZODB/POSException.py 2009-10-16 21:11:39 UTC (rev 105112)
@@ -99,6 +99,7 @@
self.message = "database conflict error"
else:
self.message = message
+ self.args = (self.message,)
if object is None:
self.oid = None
@@ -139,6 +140,9 @@
else:
return self.message
+ def __unicode__(self):
+ return unicode(str(self))
+
def get_oid(self):
return self.oid
Added: ZODB/branches/achapman-conflicterror-unicode/src/ZODB/tests/conflict_str.txt
===================================================================
--- ZODB/branches/achapman-conflicterror-unicode/src/ZODB/tests/conflict_str.txt (rev 0)
+++ ZODB/branches/achapman-conflicterror-unicode/src/ZODB/tests/conflict_str.txt 2009-10-16 21:11:39 UTC (rev 105112)
@@ -0,0 +1,35 @@
+Conflict Error Printing
+=======================
+
+
+We need to make sure ConflictErrors print correctly::
+
+ >>> import ZODB.POSException
+ >>> ce = ZODB.POSException.ConflictError()
+
+ >>> '%s %s' % (u'unicode', ce)
+ u'unicode database conflict error'
+
+ >>> '%s %s' % ('string', ce)
+ 'string database conflict error'
+
+ >>> str(ce)
+ 'database conflict error'
+
+ >>> unicode(ce)
+ u'database conflict error'
+
+ >>> ce.message = 'new'
+
+ >>> '%s %s' % (u'unicode', ce)
+ u'unicode new'
+
+ >>> '%s %s' % ('string', ce)
+ 'string new'
+
+ >>> str(ce)
+ 'new'
+
+ >>> unicode(ce)
+ u'new'
+
Modified: ZODB/branches/achapman-conflicterror-unicode/src/ZODB/tests/testconflictresolution.py
===================================================================
--- ZODB/branches/achapman-conflicterror-unicode/src/ZODB/tests/testconflictresolution.py 2009-10-16 21:09:23 UTC (rev 105111)
+++ ZODB/branches/achapman-conflicterror-unicode/src/ZODB/tests/testconflictresolution.py 2009-10-16 21:11:39 UTC (rev 105112)
@@ -36,6 +36,9 @@
tearDown=tearDown,
optionflags=doctest.INTERPRET_FOOTNOTES,
),
+ doctest.DocFileSuite('conflict_str.txt',
+ optionflags=doctest.INTERPRET_FOOTNOTES,
+ ),
))
if __name__ == '__main__':
More information about the Zodb-checkins
mailing list