Skip to content

Commit

Permalink
Backported
Browse files Browse the repository at this point in the history
r26524 | srichter | 2004-07-14 03:45:38 -0400 (Wed, 14 Jul 2004) | 6 lines
r26551 | srichter | 2004-07-15 03:06:37 -0400 (Thu, 15 Jul 2004) | 6 lines
r26522 | pruggera | 2004-07-14 01:42:06 -0400 (Wed, 14 Jul 2004) | 1 line
r26531 | pruggera | 2004-07-14 13:00:15 -0400 (Wed, 14 Jul 2004) | 1 line
r26534 | pruggera | 2004-07-14 15:55:34 -0400 (Wed, 14 Jul 2004) | 1 line
r26540 | pruggera | 2004-07-14 18:14:25 -0400 (Wed, 14 Jul 2004) | 1 line
  • Loading branch information
strichter committed Aug 12, 2004
1 parent 21616cf commit 9d92faf
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/test_directives.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Testing vocabulary directive.
$Id$
"""
import unittest

from zope.app.tests.placelesssetup import PlacelessSetup
from zope.configuration import xmlconfig
from zope.app.schema.vocabulary import ZopeVocabularyRegistry

import zope.app.schema


class MyFactory(object):
def __init__(self, context, **kw):
self.ob = context
self.kw = kw


class DirectivesTest(PlacelessSetup, unittest.TestCase):

extra_keywords = {"filter": "my-filter",
"another": "keyword"}

def check_vocabulary_get(self, kw={}):
context = object()
registry = ZopeVocabularyRegistry()
vocab = registry.get(context, "my-vocab")
self.assert_(vocab.ob is context)
self.assertEqual(vocab.kw, kw)

def test_simple_zcml(self):
self.context = xmlconfig.file("tests/simple_vocab.zcml",
zope.app.schema)
self.check_vocabulary_get()

def test_passing_keywords_from_zcml(self):
self.context = xmlconfig.file("tests/keywords_vocab.zcml",
zope.app.schema)
self.check_vocabulary_get(self.extra_keywords)


def test_suite():
return unittest.TestSuite((
unittest.makeSuite(DirectivesTest),
))

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

0 comments on commit 9d92faf

Please sign in to comment.