[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - test_vocabularywidget.py:1.1.2.14
Fred L. Drake, Jr.
fred@zope.com
Tue, 6 May 2003 15:40:58 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv25032
Modified Files:
Tag: schema-vocabulary-branch
test_vocabularywidget.py
Log Message:
- simplified BasicVocabulary.__init__()
- added docstrings to some classes
=== Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py 1.1.2.13 => 1.1.2.14 ===
--- Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py:1.1.2.13 Tue May 6 15:28:27 2003
+++ Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py Tue May 6 15:40:58 2003
@@ -31,6 +31,7 @@
"""Specialized interface so we can hook views onto a vocabulary."""
class SampleTerm(object):
+ """Trivial ITerm implementation."""
__implements__ = vocabulary.ITerm
def __init__(self, value):
@@ -38,11 +39,10 @@
class BasicVocabulary(object):
+ """Simple vocabulary that uses terms from a passed-in list of values."""
__implements__ = vocabulary.IVocabulary
- def __init__(self, values=None):
- if values is None:
- values = ["splat"]
+ def __init__(self, values):
self._values = values
def __contains__(self, value):
@@ -60,6 +60,8 @@
raise LookupError("%r not a vocabulary member" % value)
class BasicIterator(object):
+ """Iterator that produces ITerm objects from vocabulary data."""
+
def __init__(self, values):
self._next = iter(values).next
@@ -70,10 +72,15 @@
return SampleTerm(self._next())
class SampleVocabulary(BasicVocabulary):
+ """Vocabulary used to test vocabulary-based specialization of widgets."""
__implements__ = ISampleVocabulary
class SampleDisplayWidget(widget.VocabularyWidgetBase):
+ """Widget used to test that vocabulary-based specialization works.
+
+ This is not intended to be a useful widget.
+ """
__implements__ = IBrowserWidget
def render(self, value):
@@ -81,7 +88,7 @@
class SampleContent:
- pass
+ """Stub content object used by makeField()."""
class VocabularyWidgetTestBase(PlacelessSetup, unittest.TestCase):
@@ -111,7 +118,7 @@
"%r not found in %r" % (check, result))
def test_vocabulary_specialization(self):
- bound = self.makeField(SampleVocabulary())
+ bound = self.makeField(SampleVocabulary(["frobnication"]))
w = getView(bound, "display", TestRequest())
self.assertEqual(w(), "foo")