Skip to content

Commit

Permalink
Added a test for the zcml_extract
Browse files Browse the repository at this point in the history
  • Loading branch information
regebro committed Feb 17, 2016
1 parent f1d2a05 commit 347200b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CHANGES
3.7.5 (unreleased)
------------------

- Nothing changed yet.
- Added a test for the zcml_extraction.


3.7.4 (2012-05-14)
Expand Down
1 change: 0 additions & 1 deletion src/zope/app/locales/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ def zcml_strings(dir, domain="zope", site_zcml=None):
"""Retrieve all ZCML messages from `dir` that are in the `domain`.
"""
from zope.app.appsetup import config
dirname = os.path.dirname
context = config(site_zcml, features=("devmode",), execute=False)
return context.i18n_strings.get(domain, {})

Expand Down
26 changes: 26 additions & 0 deletions src/zope/app/locales/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import doctest
import os
import shutil
import tempfile
import unittest
import zope.app.locales
import zope.component
Expand Down Expand Up @@ -67,6 +69,30 @@ def test_configure_should_register_n_components(self):
s_count, len(list(gsm.registeredSubscriptionAdapters())))
self.assertEqual(h_count, len(list(gsm.registeredHandlers())))

def test_zcml_extraction(self):
zcml = """
<configure xmlns="http://namespaces.zope.org/zope"
i18n_domain="testdomain">
<include package="zope.security" file="meta.zcml" />
<permission
id="testpkg.TestPermission"
title="Test Permission"
description="This test permission is defined in ZCML"
/>
</configure>
"""
dirname = tempfile.mkdtemp()
fn = os.path.join(dirname, 'configure.zcml')
with open(fn, 'wt') as zcmlfile:
zcmlfile.write(zcml)

strings = zope.app.locales.extract.zcml_strings('unused', 'testdomain',
site_zcml=fn)
self.assertEqual(sorted(strings.keys()),
[u'Test Permission',
u'This test permission is defined in ZCML'])
shutil.rmtree(dirname)


def doctest_POTEntry_sort_order():
"""Test for POTEntry.__cmp__
Expand Down

0 comments on commit 347200b

Please sign in to comment.