[Zope3-checkins] CVS: Zope3/src/zope/app/schema/tests - test_vocabulary.py:1.1.2.3
Fred L. Drake, Jr.
fred@zope.com
Thu, 15 May 2003 10:54:00 -0400
Update of /cvs-repository/Zope3/src/zope/app/schema/tests
In directory cvs.zope.org:/tmp/cvs-serv13745
Modified Files:
Tag: schema-vocabulary-branch
test_vocabulary.py
Log Message:
- refactor to share some checks
- do a more thorough check of the constructed vocabulary in the
ZCML-based test
=== Zope3/src/zope/app/schema/tests/test_vocabulary.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/schema/tests/test_vocabulary.py:1.1.2.2 Wed May 14 13:49:08 2003
+++ Zope3/src/zope/app/schema/tests/test_vocabulary.py Thu May 15 10:53:59 2003
@@ -44,6 +44,13 @@
vocabulary.vocabularyService.get,
None, "missing-vocabulary")
+ def check_vocabulary_get(self):
+ context = object()
+ vocab = vocabulary.vocabularyService.get(context, "my-vocab")
+ self.assert_(vocab.ob is context)
+ self.assertEqual(vocab.kw, {"filter": "my-filter",
+ "another": "keyword"})
+
def test_passing_keywords_from_zcml(self):
text = """\
<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
@@ -55,10 +62,10 @@
<include package='zope.app.schema' />
<vocabulary
- name='foo'
+ name='my-vocab'
factory='zope.app.schema.tests.test_vocabulary.MyFactory'
- some='SOME'
- other='OTHER'
+ filter='my-filter'
+ another='keyword'
/>
</zopeConfigure>
"""
@@ -70,7 +77,7 @@
x()
finally:
f.close()
- r = vocabulary.vocabularyService.get(object(), "foo")
+ self.check_vocabulary_get()
def test_action_with_keywords(self):
# make sure the action machinery works, aside from ZCML concerns
@@ -86,11 +93,7 @@
# enact the registration:
callable(*args, **kw)
# make sure the factory behaves as expected:
- context = object()
- vocab = vocabulary.vocabularyService.get(context, "my-vocab")
- self.assert_(vocab.ob is context)
- self.assertEqual(vocab.kw, {"filter": "my-filter",
- "another": "keyword"})
+ self.check_vocabulary_get()
def test_suite():