[Zope3-checkins] SVN: Zope3/branches/philikon-widget-subdirective/src/zope/app/form/tests/test_utility.py handle setUp/tearDown in the doctestsuite

Philipp von Weitershausen philikon at philikon.de
Sun Jun 12 10:27:28 EDT 2005


Log message for revision 30768:
  handle setUp/tearDown in the doctestsuite
  

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

-=-
Modified: Zope3/branches/philikon-widget-subdirective/src/zope/app/form/tests/test_utility.py
===================================================================
--- Zope3/branches/philikon-widget-subdirective/src/zope/app/form/tests/test_utility.py	2005-06-12 14:24:16 UTC (rev 30767)
+++ Zope3/branches/philikon-widget-subdirective/src/zope/app/form/tests/test_utility.py	2005-06-12 14:27:28 UTC (rev 30768)
@@ -110,13 +110,13 @@
          'getAnotherBaz': True, 'setAnotherBaz': False, 'shazam': False},
         {'foo':True, 'bar': False, 'shazam': True})
 
-def setUp():
+def setUp(test):
     """Setup for tests."""
     placelesssetup.setUp()
     ztapi.browserView(IFoo, '', FooWidget, providing=IFooWidget)
     ztapi.browserView(IBar, '', BarWidget, providing=IBarWidget)
     
-def tearDown():
+def tearDown(test):
     placelesssetup.tearDown()
     
 def assertRaises(exceptionType, callable, *args):
@@ -131,8 +131,6 @@
     def test_typical(self):
         """Documents and tests the typical uses of setUpWidget.
         
-        >>> setUp()
-          
         setUpWidget ensures that the appropriate widget exists as an
         attribute of a view. There are four required arguments to the
         function:
@@ -189,15 +187,11 @@
         so we have to change that back.
 
             >>> IContent['foo'].required = True
-
-        >>> tearDown()
         """
         
     def test_validation(self):
         """Documents and tests validation performed by setUpWidget.
         
-        >>> setUp()
-            
         setUpWidget ensures that the the view has an attribute that implements
         IWidget. If setUpWidget cannot configure a widget, it raises a
         TypeError. 
@@ -223,15 +217,11 @@
             >>> assertRaises(TypeError, setUpWidget,
             ...              view, 'foo', IContent['foo'], IFooWidget)
             True
-            
-        >>> tearDown()
         """
         
     def test_context(self):
         """Documents and tests the role of context in setUpWidget.
         
-        >>> setUp()
-        
         setUpWidget configures a widget by associating it to a bound field,
         which is a copy of a schema field that is bound to an object. The
         object the field is bound to can be explicitly specified in the
@@ -255,15 +245,11 @@
             False
             >>> view.foo_widget.context.context is altContext
             True
-                    
-        >>> tearDown()
         """
         
     def test_widgetLookup(self):
         """Documents and tests how widgets are looked up by type.
         
-        >>> setUp()
-        
         If the view does not already have a widget configured for the
         specified field name, setUpWidget will look up a widget using
         an interface specified for the widgetType argument.
@@ -304,15 +290,11 @@
             >>> assertRaises(ComponentLookupError, setUpWidget,
             ...              view, 'foo', IContent['foo'], IUnregisteredWidget)
             True
-
-        >>> tearDown()
         """
         
     def test_prefix(self):
         """Documents and tests the specification of widget prefixes.
         
-        >>> setUp()
-        
         Widgets support a prefix that can be used to group related widgets
         on a view. To specify the prefix for a widget, specify in the call to
         setUpWidget:
@@ -322,15 +304,11 @@
             ...             prefix='mygroup')
             >>> view.foo_widget.getPrefix()
             'mygroup.'
-        
-        >>> tearDown()
         """
         
     def test_value(self):
         """Documents and tests values and setUpWidget.
         
-        >>> setUp()
-        
         setUpWidget configures the widget with the value specified in the
         'value' argument:
             
@@ -374,15 +352,11 @@
             True
             >>> view.foo_widget.getRenderedValue() is None
             True
-            
-        >>> tearDown()
         """
         
     def test_stickyValues(self):
         """Documents and tests setUpWidget's handling of sticky values.
         
-        >>> setUp()
-        
         setUpWidget supports the concept of 'sticky values'. A sticky value
         is a value displayed by a widget that should persist across multiple
         across multiple object edit sessions. Sticky values ensure that invalid
@@ -427,8 +401,6 @@
             ...             value="A New Value", ignoreStickyValues=True)
             >>> view.foo_widget.getRenderedValue()
             'A New Value'
-        
-        >>> tearDown()
         """
 
 class TestSetUpWidgets(object):
@@ -436,8 +408,6 @@
     def test_typical(self):
         """Tests the typical use of setUpWidgets.
         
-        >>> setUp()
-        
         The simplest use of setUpWidget configures a view with widgets of a
         particular type for a schema:
         
@@ -470,15 +440,11 @@
             'Value of Foo'
             >>> view.bar_widget.getRenderedValue()
             'Value of Bar'
-        
-        >>> tearDown()
         """        
         
     def test_names(self):
         """Documents and tests the use of names in setUpWidgets.
         
-        >>> setUp()
-        
         The names argument can be used to configure a specific set of widgets
         for a view:
             
@@ -490,15 +456,11 @@
             False
             >>> hasattr(view, 'bar_widget')
             True
-        
-        >>> tearDown()
         """
         
     def test_delegation(self):
         """Tests setUpWidgets' use of setUpWidget.
         
-        >>> setUp()
-        
         setUpWidgets delegates several of its arguments to multiple calls to
         setUpWidget - one call for each widget being configured. The arguments
         passed directly through to calls to setUpWidget are:
@@ -555,15 +517,11 @@
               True,
               'Alt Context']]
             >>> zope.app.form.utility.setUpWidget = setUpWidgetsSave
-     
-        >>> tearDown()
         """
 
     def test_forbiddenAttributes(self):
         """Tests that forbidden attributes cause an error in widget setup.
 
-        >>> setUp()
-
         If an attribute cannot be read from a source object because it's
         forbidden, the ForbiddenAttribute error is allowed to pass through
         to the caller.
@@ -593,8 +551,6 @@
             >>> setUpDisplayWidgets(view, IMySchema)
             Traceback (most recent call last):
             ForbiddenAttribute: ('some context', 'tryme')
-
-        >>> tearDown()
         """
         
 class TestFormSetUp(object):
@@ -602,8 +558,6 @@
     def test_setUpEditWidgets(self):
         """Documents and tests setUpEditWidgets.
         
-        >>> setUp()
-        
         setUpEditWidgets configures a view to collect field values from a
         user. The function looks up widgets of type IInputWidget for the 
         specified schema.
@@ -775,15 +729,11 @@
             Traceback (most recent call last):
             ...
             AttributeError: 'BrowserView' object has no attribute 'shazam_widget'
-        
-        >>> tearDown()
         """
         
     def test_setUpDisplayWidgets(self):
         """Documents and tests setUpDisplayWidgets.
         
-        >>> setUp()
-        
         setUpDisplayWidgets configures a view for use as a display only form.
         The function looks up widgets of type IDisplayWidget for the specified
         schema.
@@ -865,8 +815,6 @@
             Traceback (most recent call last):
             ...
             AttributeError: 'BrowserView' object has no attribute 'shazam_widget'
-        
-        >>> tearDown()
         """
         
 class TestForms(object):
@@ -874,8 +822,6 @@
     def test_viewHasInput(self):
         """Tests viewHasInput.
         
-        >>> setUp()
-        
         viewHasInput returns True if any of the widgets for a set of fields
         have user input.
         
@@ -904,15 +850,11 @@
             >>> view.foo_widget.input = 'Some Value'
             >>> viewHasInput(view, IContent)
             True
-            
-        >>> tearDown()
         """
         
     def test_applyWidgetsChanges(self):
         """Documents and tests applyWidgetsChanges.
         
-        >>> setUp()
-        
         applyWidgetsChanges updates the view context, or an optional alternate
         context, with widget values. This is typically called when a form
         is submitted.
@@ -1003,8 +945,6 @@
             'a'
             >>> getattr(context, 'bar', 'not really')
             'not really'
-
-        >>> tearDown()
         """
         
 class TestGetWidgetsData(object):
@@ -1012,8 +952,6 @@
     def test_typical(self):
         """Documents and tests the typical use of getWidgetsData.
         
-        >>> setUp()
-        
         getWidgetsData retrieves the current values from widgets on a view.
         For this test, we'll create a simple edit widget and register it
         for the schema field types:
@@ -1089,8 +1027,6 @@
             >>> result = getWidgetsData(view, IContent, names=('bar',))
             >>> result.keys()
             ['bar']
-            
-        >>> tearDown()
         """
         
     def test_widgetsErrorException(self):
@@ -1141,7 +1077,7 @@
             
 def test_suite():
     from zope.testing.doctest import DocTestSuite
-    return DocTestSuite()
+    return DocTestSuite(setUp=setUp, tearDown=tearDown)
 
 if __name__=='__main__':
     import unittest



More information about the Zope3-Checkins mailing list