1
##############################################################################
3
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
13
##############################################################################
14
"""Testing vocabulary directive.
16
$Id: test_directives.py 66637 2006-04-07 12:08:52Z jim $
18
# BBB 2006/02/24, to be removed after 12 months
23
from zope.app.testing.placelesssetup import PlacelessSetup
24
from zope.configuration import xmlconfig
25
from zope.app.schema.vocabulary import ZopeVocabularyRegistry
27
import zope.app.schema
30
class MyFactory(object):
31
def __init__(self, context, **kw):
36
class DirectivesTest(PlacelessSetup, unittest.TestCase):
38
extra_keywords = {"filter": "my-filter",
42
super(DirectivesTest, self).setUp()
43
self.__showwarning = warnings.showwarning
44
warnings.showwarning = lambda *a, **k: None
47
warnings.showwarning = self.__showwarning
48
super(DirectivesTest, self).tearDown()
50
def check_vocabulary_get(self, kw={}):
52
registry = ZopeVocabularyRegistry()
53
vocab = registry.get(context, "my-vocab")
54
self.assert_(vocab.ob is context)
55
self.assertEqual(vocab.kw, kw)
57
def test_simple_zcml(self):
58
self.context = xmlconfig.file("tests/simple_vocab.zcml",
60
self.check_vocabulary_get()
62
def test_passing_keywords_from_zcml(self):
63
self.context = xmlconfig.file("tests/keywords_vocab.zcml",
65
self.check_vocabulary_get(self.extra_keywords)
69
return unittest.TestSuite((
70
unittest.makeSuite(DirectivesTest),
73
if __name__ == '__main__':