-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't show BBB warnings during unittests.
Add BBB markers so that we'll remember to remove these tests when we finally remove support for the <vocabulary /> directive.
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<configure xmlns="http://namespaces.zope.org/zope"> | ||
|
||
<!-- BBB 2006/02/24, to be removed after 12 months --> | ||
|
||
<include package="zope.app.schema" file="meta.zcml"/> | ||
|
||
<vocabulary | ||
name="my-vocab" | ||
factory="zope.app.schema.tests.test_directives.MyFactory" | ||
filter="my-filter" | ||
another="keyword"/> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<configure xmlns="http://namespaces.zope.org/zope"> | ||
|
||
<!-- BBB 2006/02/24, to be removed after 12 months --> | ||
|
||
<include package="zope.app.schema" file="meta.zcml"/> | ||
|
||
<vocabulary | ||
name="my-vocab" | ||
factory="zope.app.schema.tests.test_directives.MyFactory" /> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
############################################################################## | ||
# | ||
# 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$ | ||
""" | ||
# BBB 2006/02/24, to be removed after 12 months | ||
|
||
import unittest | ||
import warnings | ||
|
||
from zope.app.testing.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 setUp(self): | ||
super(DirectivesTest, self).setUp() | ||
def ignorewarning(message, category, filename, lineno, file=None): | ||
pass | ||
warnings.showwarning = ignorewarning | ||
|
||
def tearDown(self): | ||
super(DirectivesTest, self).tearDown() | ||
warnings.resetwarnings() | ||
|
||
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() |