[Zope3-checkins] SVN: Zope3/branches/philikon-widget-subdirective/src/zope/app/form/tests/test_widget.py test for custom vocabulary widget factory

Philipp von Weitershausen philikon at philikon.de
Sun Jun 12 10:20:04 EDT 2005


Log message for revision 30765:
  test for custom vocabulary widget factory
  

Changed:
  U   Zope3/branches/philikon-widget-subdirective/src/zope/app/form/tests/test_widget.py

-=-
Modified: Zope3/branches/philikon-widget-subdirective/src/zope/app/form/tests/test_widget.py
===================================================================
--- Zope3/branches/philikon-widget-subdirective/src/zope/app/form/tests/test_widget.py	2005-06-12 14:19:29 UTC (rev 30764)
+++ Zope3/branches/philikon-widget-subdirective/src/zope/app/form/tests/test_widget.py	2005-06-12 14:20:04 UTC (rev 30765)
@@ -25,6 +25,7 @@
 
 from zope.app.form import Widget
 from zope.app.form import CustomWidgetFactory, CustomSequenceWidgetFactory
+from zope.app.form import CustomVocabularyWidgetFactory
 from zope.app.form.interfaces import IWidget
 from zope.app.testing.placelesssetup import setUp, tearDown
 
@@ -163,7 +164,7 @@
 
         >>> ow = CustomWidgetFactory(FooWidget, bar='baz')
         >>> sw = CustomSequenceWidgetFactory(ListSequenceWidget, subwidget=ow)
-        >>> widget = sw(field, TextLine(), request)
+        >>> widget = sw(field, request)
         >>> isinstance(widget, ListSequenceWidget)
         True
         >>> isinstance(widget.subwidget, CustomWidgetFactory)
@@ -174,6 +175,26 @@
         True
     """
 
+class TestCustomVocabularyWidgetFactory(object):
+    """Tests the custom vocabulary widget factory.
+
+    Custom widgets can be created using a custom widget
+    factory. Factories are used to assign attribute values to widgets
+    they create. The custom vocabulary widget factory can be used to
+    use items widgets for the Choice field:
+
+        >>> from zope.schema import Choice
+        >>> from zope.app.form.browser import SelectWidget
+        >>> field = Choice(__name__=u'foo', values=['a', 'b', 'c'])
+
+        >>> vw = CustomVocabularyWidgetFactory(SelectWidget, bar='baz')
+        >>> widget = vw(field.bind(context), request)
+        >>> isinstance(widget, SelectWidget)
+        True
+        >>> [term.value for term in widget.vocabulary]
+        ['a', 'b', 'c']
+    """
+
 def test_suite():
     return TestSuite((
         DocTestSuite(setUp=setUp, tearDown=tearDown),



More information about the Zope3-Checkins mailing list