[Checkins] SVN: zc.dict/trunk/ * Fixed tests to run with Python 2.6.
Michael Howitz
mh at gocept.com
Fri Mar 4 02:48:56 EST 2011
Log message for revision 120740:
* Fixed tests to run with Python 2.6.
* Using Python's ``doctest`` module instead of depreacted
``zope.testing.doctest``.
Changed:
U zc.dict/trunk/CHANGES.txt
U zc.dict/trunk/src/zc/dict/generations/evolve1.txt
U zc.dict/trunk/src/zc/dict/ordered.txt
U zc.dict/trunk/src/zc/dict/tests.py
-=-
Modified: zc.dict/trunk/CHANGES.txt
===================================================================
--- zc.dict/trunk/CHANGES.txt 2011-03-03 14:35:00 UTC (rev 120739)
+++ zc.dict/trunk/CHANGES.txt 2011-03-04 07:48:55 UTC (rev 120740)
@@ -1,6 +1,15 @@
1.3 (unreleased)
----------------
+1.3b2 (unreleased)
+------------------
+
+* Fixed tests to run with Python 2.6.
+
+* Using Python's ``doctest`` module instead of depreacted
+ ``zope.testing.doctest``.
+
+
1.3b1 (2009-03-16)
------------------
Modified: zc.dict/trunk/src/zc/dict/generations/evolve1.txt
===================================================================
--- zc.dict/trunk/src/zc/dict/generations/evolve1.txt 2011-03-03 14:35:00 UTC (rev 120739)
+++ zc.dict/trunk/src/zc/dict/generations/evolve1.txt 2011-03-04 07:48:55 UTC (rev 120740)
@@ -12,8 +12,20 @@
hierarchy of mappings. Applications that use OrderedDicts as internal data
structures need to take care of upgrading themselves.
-Let's create some ordered dicts [testdb]_:
+Setting up a test database:
+
+>>> from ZODB.tests.util import DB
+>>> db = DB()
+>>> conn = db.open()
+>>> class Context(object): pass
+>>> context = Context()
+>>> context.connection = conn
+>>> root = conn.root()
+
+
+Let's create some ordered dicts:
+
>>> from zc.dict import OrderedDict
>>> from persistent.list import PersistentList
>>> d1 = OrderedDict()
@@ -68,19 +80,3 @@
>>> list(d._order)
['d2', 'd1']
-
-
-.. [testdb] **Setting up a test database**
-
- >>> from ZODB.tests.util import DB
- >>> db = DB()
- >>> conn = db.open()
- >>> class Context(object): pass
- >>> context = Context()
- >>> context.connection = conn
- >>> root = conn.root()
-
-
-.. Local Variables:
-.. mode: rst
-.. End:
Modified: zc.dict/trunk/src/zc/dict/ordered.txt
===================================================================
--- zc.dict/trunk/src/zc/dict/ordered.txt 2011-03-03 14:35:00 UTC (rev 120739)
+++ zc.dict/trunk/src/zc/dict/ordered.txt 2011-03-04 07:48:55 UTC (rev 120740)
@@ -9,11 +9,11 @@
>>> d = OrderedDict()
>>> d
<zc.dict.dict.OrderedDict object at ...>
-
+
>>> d['foo'] = 'bar'
>>> len(d)
1
-
+
>>> d['bar'] = 'baz'
>>> len(d)
2
@@ -161,34 +161,34 @@
>>> d.keys()
['bar', 'beep', 'ding', 'foo']
-
+
>>> d.values()
['moo', 'beep', 'dong', 'bar']
-
+
>>> d.items()
[('bar', 'moo'), ('beep', 'beep'), ('ding', 'dong'), ('foo', 'bar')]
However, efficient iterators are available via the iter methods:
>>> iter(d)
- <generator object at ...>
+ <generator object ...>
>>> d.iterkeys()
- <generator object at ...>
-
+ <generator object ...>
+
>>> d.iteritems()
- <generator object at ...>
-
+ <generator object ...>
+
>>> d.itervalues()
- <generator object at ...>
+ <generator object ...>
popitem removes an item from the dict and returns a key-value pair:
>>> len(d)
4
-
+
>>> d.popitem()
('bar', 'moo')
-
+
>>> len(d)
3
@@ -256,7 +256,7 @@
... print 'clear'
... super(Demo, self).clear()
...
-
+
>>> demo1 = Demo()
>>> demo2 = Demo([['foo', 'bar'], ['bing', 'baz']], sha='zam')
update
Modified: zc.dict/trunk/src/zc/dict/tests.py
===================================================================
--- zc.dict/trunk/src/zc/dict/tests.py 2011-03-03 14:35:00 UTC (rev 120739)
+++ zc.dict/trunk/src/zc/dict/tests.py 2011-03-04 07:48:55 UTC (rev 120740)
@@ -11,24 +11,17 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Tests for zc.dict
+"""Tests for zc.dict"""
+import doctest
-$Id$
-"""
-import unittest
-from zope.testing import doctest
-
-optionflags = (doctest.INTERPRET_FOOTNOTES |
- doctest.REPORT_NDIFF |
+optionflags = (doctest.REPORT_NDIFF |
doctest.ELLIPSIS)
def test_suite():
- return unittest.TestSuite([
- doctest.DocFileSuite('dict.txt', 'ordered.txt',
- optionflags=optionflags),
- ])
+ return doctest.DocFileSuite('dict.txt', 'ordered.txt',
+ optionflags=optionflags)
def test_suite_generations():
@@ -36,7 +29,3 @@
suite.addTest(doctest.DocFileSuite('generations/evolve1.txt',
optionflags=optionflags))
return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
More information about the checkins
mailing list