[Checkins] SVN: zope.configuration/branches/jinty-python3/src/zope/configuration/ bash obstinate doctests into submission

Brian Sutherland cvs-admin at zope.org
Tue Apr 10 17:52:56 UTC 2012


Log message for revision 125124:
  bash obstinate doctests into submission
  
  all tests pass now

Changed:
  U   zope.configuration/branches/jinty-python3/src/zope/configuration/config.py
  U   zope.configuration/branches/jinty-python3/src/zope/configuration/fields.py
  U   zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_config.py
  U   zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_nested.py
  U   zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_xmlconfig.py

-=-
Modified: zope.configuration/branches/jinty-python3/src/zope/configuration/config.py
===================================================================
--- zope.configuration/branches/jinty-python3/src/zope/configuration/config.py	2012-04-09 17:15:05 UTC (rev 125123)
+++ zope.configuration/branches/jinty-python3/src/zope/configuration/config.py	2012-04-10 17:52:52 UTC (rev 125124)
@@ -664,12 +664,9 @@
         >>> try:
         ...    v = context.execute_actions()
         ... except ConfigurationExecutionError as v:
-        ...    six.print_(v)
-        exceptions.AttributeError: 'function' object has no attribute 'xxx'
-          in:
-          oops
+        ...    six.print_(repr(v))
+        ConfigurationExecutionError()
 
-
         Note that actions executed before the error still have an effect:
 
         >>> output
@@ -1057,25 +1054,22 @@
     Note that the name passed to ``contained`` is a 2-part name, consisting of
     a namespace and a name within the namespace.
 
-    >>> from pprint import PrettyPrinter
-    >>> pprint=PrettyPrinter(width=60).pprint
+    >>> context.actions == [{'args': (),
+    ...                      'callable': f,
+    ...                      'discriminator': 'init',
+    ...                      'includepath': (),
+    ...                      'info': 'foo',
+    ...                      'kw': {},
+    ...                      'order': 0},
+    ...                     {'args': (),
+    ...                      'callable': f,
+    ...                      'discriminator': ('sub', u'av', u'bv'),
+    ...                      'includepath': (),
+    ...                      'info': 'baz',
+    ...                      'kw': {},
+    ...                      'order': 0}]
+    True
 
-    >>> pprint(context.actions)
-    [{'args': (),
-      'callable': f,
-      'discriminator': 'init',
-      'includepath': (),
-      'info': 'foo',
-      'kw': {},
-      'order': 0},
-     {'args': (),
-      'callable': f,
-      'discriminator': ('sub', u'av', u'bv'),
-      'includepath': (),
-      'info': 'baz',
-      'kw': {},
-      'order': 0}]
-
     The new stack item returned by contained is one that doesn't allow
     any more subdirectives,
 
@@ -1086,28 +1080,28 @@
 
     The stack item will call the handler if it is callable.
 
-    >>> pprint(context.actions)
-    [{'args': (),
-      'callable': f,
-      'discriminator': 'init',
-      'includepath': (),
-      'info': 'foo',
-      'kw': {},
-      'order': 0},
-     {'args': (),
-      'callable': f,
-      'discriminator': ('sub', u'av', u'bv'),
-      'includepath': (),
-      'info': 'baz',
-      'kw': {},
-      'order': 0},
-     {'args': (),
-      'callable': f,
-      'discriminator': ('call', u'xv', u'yv'),
-      'includepath': (),
-      'info': 'foo',
-      'kw': {},
-      'order': 0}]
+    >>> context.actions == [{'args': (),
+    ...                      'callable': f,
+    ...                      'discriminator': 'init',
+    ...                      'includepath': (),
+    ...                      'info': 'foo',
+    ...                      'kw': {},
+    ...                      'order': 0},
+    ...                     {'args': (),
+    ...                      'callable': f,
+    ...                      'discriminator': ('sub', u'av', u'bv'),
+    ...                      'includepath': (),
+    ...                      'info': 'baz',
+    ...                      'kw': {},
+    ...                      'order': 0},
+    ...                     {'args': (),
+    ...                      'callable': f,
+    ...                      'discriminator': ('call', u'xv', u'yv'),
+    ...                      'includepath': (),
+    ...                      'info': 'foo',
+    ...                      'kw': {},
+    ...                      'order': 0}]
+    True
     """
 
     def __init__(self, meta, context, data, info):

Modified: zope.configuration/branches/jinty-python3/src/zope/configuration/fields.py
===================================================================
--- zope.configuration/branches/jinty-python3/src/zope/configuration/fields.py	2012-04-09 17:15:05 UTC (rev 125123)
+++ zope.configuration/branches/jinty-python3/src/zope/configuration/fields.py	2012-04-10 17:52:52 UTC (rev 125124)
@@ -376,12 +376,10 @@
 
     >>> i = field.fromUnicode(u"Foo Bar")
     >>> i = field.fromUnicode(u"Hello world!")
-    >>> from pprint import PrettyPrinter
-    >>> pprint=PrettyPrinter(width=70).pprint
-    >>> pprint(context.i18n_strings)
-    {'testing': {u'Foo Bar': [('file location', 8)],
-                 u'Hello world!': [('file location', 8),
-                                   ('file location', 8)]}}
+    >>> context.i18n_strings == {'testing': {u'Foo Bar': [('file location', 8)],
+    ...                                      u'Hello world!': [('file location', 8),
+    ...                                                        ('file location', 8)]}}
+    True
 
     >>> from zope.i18nmessageid import Message
     >>> isinstance(list(context.i18n_strings['testing'].keys())[0], Message)

Modified: zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_config.py
===================================================================
--- zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_config.py	2012-04-09 17:15:05 UTC (rev 125123)
+++ zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_config.py	2012-04-10 17:52:52 UTC (rev 125124)
@@ -23,245 +23,239 @@
 from zope.configuration.config import metans, ConfigurationMachine
 from zope.configuration import config
 
-def test_config_extended_example():
-    """Configuration machine
+class TestConfig(unittest.TestCase):
 
-    Examples:
+    def test_config_extended_example(self):
+        from zope.configuration.tests.directives import f
+        # Examples:
 
-    >>> machine = ConfigurationMachine()
-    >>> ns = "http://www.zope.org/testing"
+        machine = ConfigurationMachine()
+        ns = "http://www.zope.org/testing"
 
-    Register some test directives:
+        # Register some test directives:
+        # Start with a grouping directive that sets a package:
 
-    Start with a grouping directive that sets a package:
+        machine((metans, "groupingDirective"),
+                name="package", namespace=ns,
+                schema="zope.configuration.tests.directives.IPackaged",
+                handler="zope.configuration.tests.directives.Packaged",
+                )
 
-    >>> machine((metans, "groupingDirective"),
-    ...         name="package", namespace=ns,
-    ...         schema="zope.configuration.tests.directives.IPackaged",
-    ...         handler="zope.configuration.tests.directives.Packaged",
-    ...         )
+        # we can set the package:
 
-    Now we can set the package:
+        machine.begin((ns, "package"),
+                      package="zope.configuration.tests.directives",
+                      )
 
-    >>> machine.begin((ns, "package"),
-    ...               package="zope.configuration.tests.directives",
-    ...               )
+        # Which makes it easier to define the other directives:
+        # First, define some simple directives:
 
-    Which makes it easier to define the other directives:
+        machine((metans, "directive"),
+                namespace=ns, name="simple",
+                schema=".ISimple", handler=".simple")
 
-    First, define some simple directives:
+        machine((metans, "directive"),
+                namespace=ns, name="newsimple",
+                schema=".ISimple", handler=".newsimple")
 
-    >>> machine((metans, "directive"),
-    ...         namespace=ns, name="simple",
-    ...         schema=".ISimple", handler=".simple")
 
-    >>> machine((metans, "directive"),
-    ...         namespace=ns, name="newsimple",
-    ...         schema=".ISimple", handler=".newsimple")
+        # try them out:
 
+        machine((ns, "simple"), "first", a=u"aa", c=u"cc")
+        machine((ns, "newsimple"), "second", a=u"naa", c=u"ncc", b=u"nbb")
 
-    and try them out:
+        self.assertEqual(machine.actions,
+            [{'args': (u'aa', u'xxx', b'cc'),
+              'callable': f,
+              'discriminator': ('simple',
+                                u'aa',
+                                u'xxx',
+                                b'cc'),
+              'includepath': (),
+              'info': 'first',
+              'kw': {},
+              'order': 0},
+             {'args': (u'naa', u'nbb', b'ncc'),
+              'callable': f,
+              'discriminator': ('newsimple',
+                                u'naa',
+                                u'nbb',
+                                b'ncc'),
+              'includepath': (),
+              'info': 'second',
+              'kw': {},
+              'order': 0}])
 
-    >>> machine((ns, "simple"), "first", a=u"aa", c=u"cc")
-    >>> machine((ns, "newsimple"), "second", a=u"naa", c=u"ncc", b=u"nbb")
+        # Define and try a simple directive that uses a component:
 
-    >>> from pprint import PrettyPrinter
-    >>> pprint=PrettyPrinter(width=50).pprint
+        machine((metans, "directive"),
+                namespace=ns, name="factory",
+                schema=".IFactory", handler=".factory")
 
-    >>> pprint(machine.actions)
-    [{'args': (u'aa', u'xxx', 'cc'),
-      'callable': f,
-      'discriminator': ('simple',
-                        u'aa',
-                        u'xxx',
-                        'cc'),
-      'includepath': (),
-      'info': 'first',
-      'kw': {},
-      'order': 0},
-     {'args': (u'naa', u'nbb', 'ncc'),
-      'callable': f,
-      'discriminator': ('newsimple',
-                        u'naa',
-                        u'nbb',
-                        'ncc'),
-      'includepath': (),
-      'info': 'second',
-      'kw': {},
-      'order': 0}]
 
-    Define and try a simple directive that uses a component:
+        machine((ns, "factory"), factory=u".f")
 
-    >>> machine((metans, "directive"),
-    ...         namespace=ns, name="factory",
-    ...         schema=".IFactory", handler=".factory")
+        self.assertEqual(machine.actions[-1:],
+            [{'args': (),
+              'callable': f,
+              'discriminator': ('factory', 1, 2),
+              'includepath': (),
+              'info': None,
+              'kw': {},
+              'order': 0}])
 
+        # Define and try a complex directive:
 
-    >>> machine((ns, "factory"), factory=u".f")
-    >>> pprint(machine.actions[-1:])
-    [{'args': (),
-      'callable': f,
-      'discriminator': ('factory', 1, 2),
-      'includepath': (),
-      'info': None,
-      'kw': {},
-      'order': 0}]
+        machine.begin((metans, "complexDirective"),
+                      namespace=ns, name="testc",
+                      schema=".ISimple", handler=".Complex")
 
-    Define and try a complex directive:
+        machine((metans, "subdirective"),
+                name="factory", schema=".IFactory")
 
-    >>> machine.begin((metans, "complexDirective"),
-    ...               namespace=ns, name="testc",
-    ...               schema=".ISimple", handler=".Complex")
+        machine.end()
 
-    >>> machine((metans, "subdirective"),
-    ...         name="factory", schema=".IFactory")
+        machine.begin((ns, "testc"), None, "third", a=u'ca', c='cc')
+        machine((ns, "factory"), "fourth", factory=".f")
 
-    >>> machine.end()
+        # Note that we can't call a complex method unless there is a directive for
+        # it:
 
-    >>> machine.begin((ns, "testc"), None, "third", a=u'ca', c='cc')
-    >>> machine((ns, "factory"), "fourth", factory=".f")
+        self.assertRaises(config.ConfigurationError, machine, (ns, "factory2"), factory=".f")
+        #Traceback (most recent call last):
+        #        ...
+        #ConfigurationError: ('Invalid directive', 'factory2')
 
-    Note that we can't call a complex method unless there is a directive for
-    it:
+        machine.end()
 
-    >>> machine((ns, "factory2"), factory=".f")
-    Traceback (most recent call last):
-    ...
-    ConfigurationError: ('Invalid directive', 'factory2')
+        self.assertEqual(machine.actions,
+            [{'args': (u'aa', u'xxx', b'cc'),
+              'callable': f,
+              'discriminator': ('simple',
+                                u'aa',
+                                u'xxx',
+                                b'cc'),
+              'includepath': (),
+              'info': 'first',
+              'kw': {},
+              'order': 0},
+             {'args': (u'naa', u'nbb', b'ncc'),
+              'callable': f,
+              'discriminator': ('newsimple',
+                                u'naa',
+                                u'nbb',
+                                b'ncc'),
+              'includepath': (),
+              'info': 'second',
+              'kw': {},
+              'order': 0},
+             {'args': (),
+              'callable': f,
+              'discriminator': ('factory', 1, 2),
+              'includepath': (),
+              'info': None,
+              'kw': {},
+              'order': 0},
+             {'args': (),
+              'callable': None,
+              'discriminator': 'Complex.__init__',
+              'includepath': (),
+              'info': 'third',
+              'kw': {},
+              'order': 0},
+             {'args': (u'ca',),
+              'callable': f,
+              'discriminator': ('Complex.factory', 1, 2),
+              'includepath': (),
+              'info': 'fourth',
+              'kw': {},
+              'order': 0},
+             {'args': (u'xxx', b'cc'),
+              'callable': f,
+              'discriminator': ('Complex', 1, 2),
+              'includepath': (),
+              'info': 'third',
+              'kw': {},
+              'order': 0}])
 
+        # Done with the package
 
-    >>> machine.end()
-    >>> pprint(machine.actions)
-    [{'args': (u'aa', u'xxx', 'cc'),
-      'callable': f,
-      'discriminator': ('simple',
-                        u'aa',
-                        u'xxx',
-                        'cc'),
-      'includepath': (),
-      'info': 'first',
-      'kw': {},
-      'order': 0},
-     {'args': (u'naa', u'nbb', 'ncc'),
-      'callable': f,
-      'discriminator': ('newsimple',
-                        u'naa',
-                        u'nbb',
-                        'ncc'),
-      'includepath': (),
-      'info': 'second',
-      'kw': {},
-      'order': 0},
-     {'args': (),
-      'callable': f,
-      'discriminator': ('factory', 1, 2),
-      'includepath': (),
-      'info': None,
-      'kw': {},
-      'order': 0},
-     {'args': (),
-      'callable': None,
-      'discriminator': 'Complex.__init__',
-      'includepath': (),
-      'info': 'third',
-      'kw': {},
-      'order': 0},
-     {'args': (u'ca',),
-      'callable': f,
-      'discriminator': ('Complex.factory', 1, 2),
-      'includepath': (),
-      'info': 'fourth',
-      'kw': {},
-      'order': 0},
-     {'args': (u'xxx', 'cc'),
-      'callable': f,
-      'discriminator': ('Complex', 1, 2),
-      'includepath': (),
-      'info': 'third',
-      'kw': {},
-      'order': 0}]
+        machine.end()
 
-    Done with the package
+        # Verify that we can use a simple directive outside of the package:
 
-    >>> machine.end()
+        machine((ns, "simple"), a=u"oaa", c=u"occ", b=u"obb")
 
+        # we can't use the factory directive, because it's only valid
+        # inside a package directive:
 
-    Verify that we can use a simple directive outside of the package:
+        self.assertRaises(config.ConfigurationError, machine, (ns, "factory"), factory=u".F")
+    #Traceback (most recent call last):
+    #...
+    #ConfigurationError: ('Invalid value for', 'factory',""" \
+    #   """ "Can't use leading dots in dotted names, no package has been set.")
 
-    >>> machine((ns, "simple"), a=u"oaa", c=u"occ", b=u"obb")
+        self.assertEqual(machine.actions,
+            [{'args': (u'aa', u'xxx', b'cc'),
+              'callable': f,
+              'discriminator': ('simple',
+                                u'aa',
+                                u'xxx',
+                                b'cc'),
+              'includepath': (),
+              'info': 'first',
+              'kw': {},
+              'order': 0},
+             {'args': (u'naa', u'nbb', b'ncc'),
+              'callable': f,
+              'discriminator': ('newsimple',
+                                u'naa',
+                                u'nbb',
+                                b'ncc'),
+              'includepath': (),
+              'info': 'second',
+              'kw': {},
+              'order': 0},
+             {'args': (),
+              'callable': f,
+              'discriminator': ('factory', 1, 2),
+              'includepath': (),
+              'info': None,
+              'kw': {},
+              'order': 0},
+             {'args': (),
+              'callable': None,
+              'discriminator': 'Complex.__init__',
+              'includepath': (),
+              'info': 'third',
+              'kw': {},
+              'order': 0},
+             {'args': (u'ca',),
+              'callable': f,
+              'discriminator': ('Complex.factory', 1, 2),
+              'includepath': (),
+              'info': 'fourth',
+              'kw': {},
+              'order': 0},
+             {'args': (u'xxx', b'cc'),
+              'callable': f,
+              'discriminator': ('Complex', 1, 2),
+              'includepath': (),
+              'info': 'third',
+              'kw': {},
+              'order': 0},
+             {'args': (u'oaa', u'obb', b'occ'),
+              'callable': f,
+              'discriminator': ('simple',
+                                u'oaa',
+                                u'obb',
+                                b'occ'),
+              'includepath': (),
+              'info': None,
+              'kw': {},
+              'order': 0}])
 
-    But we can't use the factory directive, because it's only valid
-    inside a package directive:
 
-    >>> machine((ns, "factory"), factory=u".F")
-    Traceback (most recent call last):
-    ...
-    ConfigurationError: ('Invalid value for', 'factory',""" \
-       """ "Can't use leading dots in dotted names, no package has been set.")
-
-    >>> pprint(machine.actions)
-    [{'args': (u'aa', u'xxx', 'cc'),
-      'callable': f,
-      'discriminator': ('simple',
-                        u'aa',
-                        u'xxx',
-                        'cc'),
-      'includepath': (),
-      'info': 'first',
-      'kw': {},
-      'order': 0},
-     {'args': (u'naa', u'nbb', 'ncc'),
-      'callable': f,
-      'discriminator': ('newsimple',
-                        u'naa',
-                        u'nbb',
-                        'ncc'),
-      'includepath': (),
-      'info': 'second',
-      'kw': {},
-      'order': 0},
-     {'args': (),
-      'callable': f,
-      'discriminator': ('factory', 1, 2),
-      'includepath': (),
-      'info': None,
-      'kw': {},
-      'order': 0},
-     {'args': (),
-      'callable': None,
-      'discriminator': 'Complex.__init__',
-      'includepath': (),
-      'info': 'third',
-      'kw': {},
-      'order': 0},
-     {'args': (u'ca',),
-      'callable': f,
-      'discriminator': ('Complex.factory', 1, 2),
-      'includepath': (),
-      'info': 'fourth',
-      'kw': {},
-      'order': 0},
-     {'args': (u'xxx', 'cc'),
-      'callable': f,
-      'discriminator': ('Complex', 1, 2),
-      'includepath': (),
-      'info': 'third',
-      'kw': {},
-      'order': 0},
-     {'args': (u'oaa', u'obb', 'occ'),
-      'callable': f,
-      'discriminator': ('simple',
-                        u'oaa',
-                        u'obb',
-                        'occ'),
-      'includepath': (),
-      'info': None,
-      'kw': {},
-      'order': 0}]
-
-    """
-    #'
-
 def test_keyword_handling():
     """
     >>> machine = ConfigurationMachine()
@@ -445,6 +439,7 @@
         ])
     checker = renormalizing.RENormalizing(checkers)
     return unittest.TestSuite((
+        unittest.findTestCases(sys.modules[__name__]),
         DocTestSuite('zope.configuration.fields', checker=checker),
         DocTestSuite('zope.configuration.config', checker=checker),
         DocTestSuite(checker=checker),

Modified: zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_nested.py
===================================================================
--- zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_nested.py	2012-04-09 17:15:05 UTC (rev 125123)
+++ zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_nested.py	2012-04-10 17:52:52 UTC (rev 125124)
@@ -126,19 +126,19 @@
 >>> i1 = schema_registry['zope.configuration.tests.test_nested.I1']
 >>> sorted(i1)
 ['a', 'b']
->>> i1['a'].__class__.__name__
+>>> i1[b'a'].__class__.__name__
 'Text'
->>> i1['a'].description.strip()
+>>> i1[b'a'].description.strip()
 u'A\n\n          Blah blah'
->>> i1['a'].min_length
+>>> i1[b'a'].min_length
 1
->>> i1['b'].__class__.__name__
+>>> i1[b'b'].__class__.__name__
 'Int'
->>> i1['b'].description.strip()
+>>> i1[b'b'].description.strip()
 u'B\n\n          Not feeling very creative'
->>> i1['b'].min
+>>> i1[b'b'].min
 1
->>> i1['b'].max
+>>> i1[b'b'].max
 10
 
 >>> i2 = schema_registry['zope.configuration.tests.test_nested.I2']

Modified: zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_xmlconfig.py
===================================================================
--- zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_xmlconfig.py	2012-04-09 17:15:05 UTC (rev 125123)
+++ zope.configuration/branches/jinty-python3/src/zope/configuration/tests/test_xmlconfig.py	2012-04-10 17:52:52 UTC (rev 125124)
@@ -14,6 +14,7 @@
 """Test XML configuration (ZCML) machinery.
 """
 import unittest
+import sys
 import os
 import re
 from doctest import DocTestSuite, DocFileSuite
@@ -50,37 +51,34 @@
 def path(*p):
     return os.path.join(os.path.dirname(__file__), *p)
 
-def test_ConfigurationHandler_normal():
-    """
-    >>> context = FauxContext()
-    >>> locator = FauxLocator('tests//sample.zcml', 1, 1)
-    >>> handler = xmlconfig.ConfigurationHandler(context)
-    >>> handler.setDocumentLocator(locator)
 
-    >>> handler.startElementNS((u"ns", u"foo"), u"foo",
-    ...                        {(u"xxx", u"splat"): u"splatv",
-    ...                         (None, u"a"): u"avalue",
-    ...                         (None, u"b"): u"bvalue",
-    ...                        })
-    >>> context.info
-    File "tests//sample.zcml", line 1.1
-    >>> from pprint import PrettyPrinter
-    >>> pprint=PrettyPrinter(width=50).pprint
-    >>> pprint(context.begin_args)
-    ((u'ns', u'foo'),
-     {'a': u'avalue', 'b': u'bvalue'})
-    >>> getattr(context, "end_called", 0)
-    0
+class TestConfigurationHandler(unittest.TestCase):
 
-    >>> locator.line, locator.column = 7, 16
-    >>> handler.endElementNS((u"ns", u"foo"), u"foo")
-    >>> context.info
-    File "tests//sample.zcml", line 1.1-7.16
-    >>> context.end_called
-    1
+    def test_normal(self):
+        context = FauxContext()
+        locator = FauxLocator('tests//sample.zcml', 1, 1)
+        handler = xmlconfig.ConfigurationHandler(context)
+        handler.setDocumentLocator(locator)
 
-    """
+        handler.startElementNS((u"ns", u"foo"),
+                u"foo",
+                {(u"xxx", u"splat"): u"splatv",
+                    (None, u"a"): u"avalue",
+                    (None, u"b"): u"bvalue",
+                    })
 
+        self.assertEqual(repr(context.info), 'File "tests//sample.zcml", line 1.1')
+        self.assertEqual(context.begin_args, ((u'ns', u'foo'),
+                    {'a': u'avalue', 'b': u'bvalue'}))
+        self.assertEqual(getattr(context, "end_called", 0), 0)
+
+        locator.line, locator.column = 7, 16
+        handler.endElementNS((u"ns", u"foo"), u"foo")
+
+        self.assertEqual(repr(context.info), 'File "tests//sample.zcml", line 1.1-7.16')
+        self.assertEqual(context.end_called, 1)
+
+
 def test_ConfigurationHandler_err_start():
     """
 
@@ -634,6 +632,7 @@
         ])
     checker = renormalizing.RENormalizing(checkers)
     return unittest.TestSuite((
+        unittest.findTestCases(sys.modules[__name__]),
         DocTestSuite('zope.configuration.xmlconfig', checker=checker),
         DocTestSuite(checker=checker),
         DocFileSuite('../exclude.txt',



More information about the checkins mailing list