Skip to content

Commit

Permalink
Make sure ZCML works with a test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Aug 5, 2016
1 parent 345b7c1 commit 9e7e550
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Changes

- Drop support for Python 2.6.

- Fix configuring the package via its included ZCML on Python 3.

2.0.0 (2014-12-24)
--------------------
Expand Down
19 changes: 19 additions & 0 deletions src/zope/mimetype/configure.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Package configuration
=====================

The ``zope.mimetype`` package provides a ZCML file that configures some
adapters and utilities and a couple of views:

>>> from zope.configuration.xmlconfig import XMLConfig
>>> import zope.mimetype

>>> len(list(zope.component.getGlobalSiteManager().registeredUtilities()))
0

>>> XMLConfig('configure.zcml', zope.mimetype)()

>>> len(list(zope.component.getGlobalSiteManager().registeredUtilities())) >= 760
True

>>> len(list(zope.component.getGlobalSiteManager().registeredAdapters()))
107
3 changes: 3 additions & 0 deletions src/zope/mimetype/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
xmlns="http://namespaces.zope.org/zope"
i18n_domain="zope.mimetype">

<include package="zope.component" file="meta.zcml" />
<include package="zope.mimetype" file="meta.zcml" />

<mimeTypes
module=".mtypes"
file="types.csv"
Expand Down
13 changes: 9 additions & 4 deletions src/zope/mimetype/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,15 @@ def test_suite():
setUp=testing.setUp, tearDown=testing.tearDown,
checker=checker),
doctest.DocFileSuite(
'codec.txt',
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
checker=checker,
),
'codec.txt',
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
checker=checker,
),
doctest.DocFileSuite(
'configure.txt',
setUp=testing.setUp, tearDown=testing.tearDown,
checker=checker
),
))

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion src/zope/mimetype/zcml.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def mimeTypesDirective(_context, file, module):
directory = os.path.dirname(file)
data = mtypes.read(file)
provides = interfaces.IContentTypeInterface
for name, info in data.iteritems():
for name, info in data.items():
iface = getattr(module, name, None)
if iface is None:
# create missing interface
Expand Down

0 comments on commit 9e7e550

Please sign in to comment.