Skip to content

Commit

Permalink
Include zcml dependencies in configure.zcml, require the necessar…
Browse files Browse the repository at this point in the history
…y packages via a `zcml` extra, added tests for zcml.
  • Loading branch information
Michael Howitz committed Mar 2, 2011
1 parent d9dceb4 commit fdaef78
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Expand Up @@ -5,9 +5,13 @@ CHANGES
3.6.3 (unreleased)
------------------

- Include zcml dependencies in ``configure.zcml``, require the necessary
packages via a `zcml` extra, added tests for zcml.

- Using Python's ``doctest`` module instead of depreacted
``zope.testing.doctest``.


3.6.2 (2010-07-31)
------------------

Expand Down
2 changes: 1 addition & 1 deletion buildout.cfg
Expand Up @@ -11,4 +11,4 @@ arguments = ['-p', 'testproj/src', '-s', 'testproj/site.zcml',

[test]
recipe = zc.recipe.testrunner
eggs = zope.app.locales [test]
eggs = zope.app.locales [test,zcml]
4 changes: 4 additions & 0 deletions setup.py
Expand Up @@ -68,6 +68,10 @@ def read(*rnames):
'zope.tal',
'zope.testing',
],
zcml=[
'zope.i18n',
'zope.configuration',
],
extract=[
'zope.tal',
'zope.app.applicationcontrol',
Expand Down
2 changes: 2 additions & 0 deletions src/zope/app/locales/configure.zcml
Expand Up @@ -2,6 +2,8 @@
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="zope">

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

<i18n:registerTranslations directory="." />

</configure>
32 changes: 28 additions & 4 deletions src/zope/app/locales/tests.py
Expand Up @@ -13,9 +13,12 @@
##############################################################################
"""Tests for the message string extraction tool."""

import os
import doctest
import os
import unittest
import zope.app.locales
import zope.component
import zope.configuration.xmlconfig


class TestIsUnicodeInAllCatalog(unittest.TestCase):
Expand All @@ -42,14 +45,35 @@ def test_is_unicode(self):
The language is %s (zope.po).
Value of the message catalog should be in unicode""" % (lang,)
)
class ZCMLTest(unittest.TestCase):

def test_configure_zcml_should_be_loadable(self):
try:
zope.configuration.xmlconfig.XMLConfig(
'configure.zcml', zope.app.locales)()
except Exception, e:
self.fail(e)

def test_configure_should_register_n_components(self):
gsm = zope.component.getGlobalSiteManager()
u_count = len(list(gsm.registeredUtilities()))
a_count = len(list(gsm.registeredAdapters()))
s_count = len(list(gsm.registeredSubscriptionAdapters()))
h_count = len(list(gsm.registeredHandlers()))
zope.configuration.xmlconfig.XMLConfig(
'configure.zcml', zope.app.locales)()
self.assertEqual(u_count + 2, len(list(gsm.registeredUtilities())))
self.assertEqual(a_count, len(list(gsm.registeredAdapters())))
self.assertEqual(
s_count, len(list(gsm.registeredSubscriptionAdapters())))
self.assertEqual(h_count, len(list(gsm.registeredHandlers())))



def test_suite():
return unittest.TestSuite((
doctest.DocTestSuite('zope.app.locales.extract',
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,),
unittest.makeSuite(TestIsUnicodeInAllCatalog),
unittest.makeSuite(ZCMLTest),
))

if __name__ == '__main__':
unittest.main()

0 comments on commit fdaef78

Please sign in to comment.