Skip to content

Commit

Permalink
Flesh out the docs for includeOverrides a little bit.
Browse files Browse the repository at this point in the history
Fixes #8.

Also correct a usage of logger.debug() to not format prematurely. This
caused some changes to a doctest, so this is based on #24.

Remove the usage of _compat.u in xmlconfig.py and fix its pragmas to
match .coveragerc.

Fix the version number reported to Sphinx.
  • Loading branch information
jamadden committed Sep 24, 2018
1 parent 51b58df commit 92812e6
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 81 deletions.
12 changes: 8 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import sys
import os
import pkg_resources
sys.path.append(os.path.abspath('../src'))
rqmt = pkg_resources.require('zope.configuration')[0]

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -54,9 +58,9 @@
# built documents.
#
# The short X.Y version.
version = '4.0'
version = '%s.%s' % tuple(map(int, rqmt.version.split('.')[:2]))
# The full version, including alpha/beta/rc tags.
release = '4.0'
release = rqmt.version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -73,7 +77,7 @@
exclude_patterns = ['_build']

# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
default_role = 'obj'

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
Expand Down
6 changes: 3 additions & 3 deletions docs/narr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ Now, we'll include the zope.configuration.tests.excludedemo config:
>>> _ = string('<include package="zope.configuration.tests.excludedemo" />')
>>> len(handler.buffer)
3
>>> logged = [x.msg for x in handler.buffer]
>>> logged = [x.getMessage() for x in handler.buffer]
>>> logged[0].startswith('include ')
True
>>> logged[0].endswith('zope/configuration/tests/excludedemo/configure.zcml')
Expand All @@ -708,7 +708,7 @@ rerunning gives the same thing:
>>> _ = string('<include package="zope.configuration.tests.excludedemo" />')
>>> len(handler.buffer)
3
>>> logged = [x.msg for x in handler.buffer]
>>> logged = [x.getMessage() for x in handler.buffer]
>>> logged[0].startswith('include ')
True
>>> logged[0].endswith('zope/configuration/tests/excludedemo/configure.zcml')
Expand Down Expand Up @@ -738,7 +738,7 @@ by the configuration file in zope.configuration.tests.excludedemo:
... ''')
>>> len(handler.buffer)
1
>>> logged = [x.msg for x in handler.buffer]
>>> logged = [x.getMessage() for x in handler.buffer]
>>> logged[0].startswith('include ')
True
>>> logged[0].endswith('zope/configuration/tests/excludedemo/configure.zcml')
Expand Down
47 changes: 14 additions & 33 deletions src/zope/configuration/tests/test_xmlconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def test_neither_file_nor_files_passed(self):
with _Monkey(xmlconfig, logger=logger):
self._callFUT(context)
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % fqn, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (fqn,), {}))
self.assertEqual(len(context.actions), 1)
action = context.actions[0]
self.assertEqual(action['callable'], foo.data.append)
Expand All @@ -511,7 +511,7 @@ def test_w_file_passed(self):
with _Monkey(xmlconfig, logger=logger):
self._callFUT(context, 'simple.zcml')
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % fqn, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (fqn,), {}))
self.assertEqual(len(context.actions), 3)
action = context.actions[0]
self.assertEqual(action['callable'], simple.file_registry.append)
Expand Down Expand Up @@ -549,9 +549,9 @@ def test_w_files_passed_and_package(self):
with _Monkey(xmlconfig, logger=logger):
self._callFUT(context, package=samplepackage, files='baz*.zcml')
self.assertEqual(len(logger.debugs), 3)
self.assertEqual(logger.debugs[0], ('include %s' % fqn1, (), {}))
self.assertEqual(logger.debugs[1], ('include %s' % fqn2, (), {}))
self.assertEqual(logger.debugs[2], ('include %s' % fqn3, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (fqn1,), {}))
self.assertEqual(logger.debugs[1], ('include %s', (fqn2,), {}))
self.assertEqual(logger.debugs[2], ('include %s', (fqn3,), {}))
self.assertEqual(len(context.actions), 2)
action = context.actions[0]
self.assertEqual(action['callable'], foo.data.append)
Expand Down Expand Up @@ -665,7 +665,7 @@ def _callable():
with _Monkey(xmlconfig, logger=logger):
self._callFUT(context, 'simple.zcml')
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % fqn, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (fqn,), {}))
self.assertEqual(len(context.actions), 4)
action = context.actions[0]
self.assertEqual(action['discriminator'], None)
Expand Down Expand Up @@ -705,7 +705,7 @@ def test_wo_execute_wo_context_wo_package(self):
with _Monkey(xmlconfig, logger=logger):
context = self._callFUT(file_name, execute=False)
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % file_name, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (file_name,), {}))
self.assertEqual(len(foo.data), 0)
self.assertEqual(len(context.actions), 1)
action = context.actions[0]
Expand All @@ -724,7 +724,7 @@ def test_wo_execute_wo_context_w_package(self):
context = self._callFUT('configure.zcml', package=samplepackage,
execute=False)
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % file_name, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (file_name,), {}))
self.assertEqual(len(foo.data), 0)
self.assertTrue(context.package is samplepackage)
self.assertEqual(len(context.actions), 1)
Expand All @@ -750,7 +750,7 @@ def test_wo_execute_w_context(self):
execute=False)
self.assertTrue(ret is context)
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % file_name, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (file_name,), {}))
self.assertEqual(len(foo.data), 0)
self.assertEqual(len(context.actions), 1)
action = context.actions[0]
Expand All @@ -768,7 +768,7 @@ def test_w_execute(self):
with _Monkey(xmlconfig, logger=logger):
context = self._callFUT(file_name)
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % file_name, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (file_name,), {}))
data = foo.data.pop()
self.assertEqual(data.args, (('x', b('blah')), ('y', 0)))
self.assertTrue(
Expand Down Expand Up @@ -873,7 +873,7 @@ def test_ctor_w_global_context_missing(self):
with _Monkey(xmlconfig, logger=logger):
xc = self._makeOne(path)
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % path, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (path,), {}))
self.assertEqual(len(foo.data), 0) # no execut_actions
self.assertEqual(len(xc.context.actions), 1)
action = xc.context.actions[0]
Expand All @@ -891,7 +891,7 @@ def test_ctor(self):
with _Monkey(xmlconfig, logger=logger):
xc = self._makeOne(fqn)
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % fqn, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (fqn,), {}))
self.assertEqual(len(foo.data), 0) # no execut_actions
self.assertEqual(len(xc.context.actions), 1)
action = xc.context.actions[0]
Expand All @@ -909,7 +909,7 @@ def test_ctor_w_module(self):
with _Monkey(xmlconfig, logger=logger):
xc = self._makeOne("configure.zcml", samplepackage)
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % fqn, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (fqn,), {}))
self.assertEqual(len(foo.data), 0) # no execut_actions
self.assertEqual(len(xc.context.actions), 1)
action = xc.context.actions[0]
Expand All @@ -928,7 +928,7 @@ def test___call__(self):
with _Monkey(xmlconfig, logger=logger):
xc = self._makeOne(fqn)
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s' % fqn, (), {}))
self.assertEqual(logger.debugs[0], ('include %s', (fqn,), {}))
self.assertEqual(len(foo.data), 0)
xc() # call to process the actions
self.assertEqual(len(foo.data), 1)
Expand Down Expand Up @@ -1184,22 +1184,3 @@ def info(self, msg, *args, **kwargs):

def debug(self, msg, *args, **kwargs):
self.debugs.append((msg, args, kwargs))


def test_suite():
return unittest.TestSuite((
unittest.makeSuite(ZopeXMLConfigurationErrorTests),
unittest.makeSuite(ZopeSAXParseExceptionTests),
unittest.makeSuite(ParserInfoTests),
unittest.makeSuite(ConfigurationHandlerTests),
unittest.makeSuite(Test_processxmlfile),
unittest.makeSuite(Test_openInOrPlain),
unittest.makeSuite(Test_include),
unittest.makeSuite(Test_exclude),
unittest.makeSuite(Test_includeOverrides),
unittest.makeSuite(Test_file),
unittest.makeSuite(Test_string),
unittest.makeSuite(XMLConfigTests),
unittest.makeSuite(Test_xmlconfig),
unittest.makeSuite(Test_testxmlconfig),
))
Loading

0 comments on commit 92812e6

Please sign in to comment.