[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - test_add.py:1.22 test_browserwidget.py:1.17 test_editview.py:1.15 test_vocabularywidget.py:1.27 test_widget_deprecations.py:1.2

Philipp von Weitershausen cvs-admin at zope.org
Thu Nov 27 08:59:44 EST 2003


Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv22470/browser/form/tests

Modified Files:
	test_add.py test_browserwidget.py test_editview.py 
	test_vocabularywidget.py test_widget_deprecations.py 
Log Message:
Use super in test setUp methods. We can do this now because TestCase
(finally!) is a new-style class Python 2.3.


=== Zope3/src/zope/app/browser/form/tests/test_add.py 1.21 => 1.22 ===
--- Zope3/src/zope/app/browser/form/tests/test_add.py:1.21	Fri Nov 21 12:11:56 2003
+++ Zope3/src/zope/app/browser/form/tests/test_add.py	Thu Nov 27 08:59:13 2003
@@ -92,7 +92,7 @@
 
     def setUp(self):
         self._context = Context()
-        PlacelessSetup.setUp(self)
+        super(Test, self).setUp()
         ztapi.provideAdapter(IFoo, IBar, FooBarAdapter)
 
     def _invoke_add(self, schema=I, name="addthis", permission="zope.Public",


=== Zope3/src/zope/app/browser/form/tests/test_browserwidget.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/browser/form/tests/test_browserwidget.py:1.16	Sat Aug 16 13:23:37 2003
+++ Zope3/src/zope/app/browser/form/tests/test_browserwidget.py	Thu Nov 27 08:59:13 2003
@@ -53,7 +53,7 @@
         self._widget = self._WidgetFactory(field, request)
 
     def setUp(self):
-        PlacelessSetup.setUp(self)
+        super(BrowserWidgetTest, self).setUp()
         self.setUpContent()
 
     def test_required(self):


=== Zope3/src/zope/app/browser/form/tests/test_editview.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/browser/form/tests/test_editview.py:1.14	Fri Nov 21 12:11:56 2003
+++ Zope3/src/zope/app/browser/form/tests/test_editview.py	Thu Nov 27 08:59:13 2003
@@ -79,7 +79,7 @@
 class Test(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
-        PlacelessSetup.setUp(self)
+        super(Test, self).setUp()
         ztapi.browserView(ITextLine, 'edit', TextWidget)
         ztapi.setDefaultViewName(ITextLine, "edit")
         ztapi.provideAdapter(IFoo, IBar, FooBarAdapter)


=== Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py 1.26 => 1.27 ===
--- Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py:1.26	Fri Nov 21 12:11:56 2003
+++ Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py	Thu Nov 27 08:59:13 2003
@@ -109,7 +109,7 @@
     """
 
     def setUp(self):
-        PlacelessSetup.setUp(self)
+        super(VocabularyWidgetTestBase, self).setUp()
         self.registerViews()
 
     # makeField() uses the following class variables:


=== Zope3/src/zope/app/browser/form/tests/test_widget_deprecations.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/form/tests/test_widget_deprecations.py:1.1	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_widget_deprecations.py	Thu Nov 27 08:59:13 2003
@@ -1,117 +1,117 @@
-##############################################################################
-#
-# 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.0 (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.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-import unittest
-import random
-
-from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.app.browser.form.widget import BrowserWidget
-from zope.app.form import widget
-from zope.app.browser.form import widget as browserwidget
-from zope.publisher.browser import TestRequest
-from zope.schema import Text
-
-
-class OldWidget(BrowserWidget):
-    """Simulates a typical browser widget before the renaming of:
-    
-        getData -> getInputValue
-        setData -> setRenderedValue
-        haveData -> hasInput
-    """
-
-    def __init__(self, context, request):
-        super(OldWidget, self).__init__(context, request)
-        self._data = random.random() > 0.5 and u'foo' or None
-
-    def haveData(self):
-        return self._data is None
-
-    def getData(self):
-        return self._data
-
-
-warnings = []
-
-def warn(*args, **wk):
-    warnings.append(args[1]) # append the exception class
-
-
-class TestOldWidget(PlacelessSetup, unittest.TestCase):
-
-    def setUp(self):
-        PlacelessSetup.setUp(self)
-        self._widget = OldWidget(Text(__name__='test'), TestRequest())
-        widget.warn = warn
-        browserwidget.warn = warn
-        global warnings
-        warnings = []
-
-    def test_haveInput(self):
-        self.assertEqual(self._widget.haveData(), self._widget.hasInput())
-    
-    def test_getData(self):
-        self.assertEqual(self._widget.getData(), self._widget.getInputValue())
-    
-    def test_setData(self):
-        self.assertEqual(len(warnings), 0)
-        self._widget.setData(u'bar')
-        self.assertEqual(self._widget.getInputValue(), u'bar')
-        self.assertEqual(len(warnings), 1)
-        self.assertEqual(warnings[0], DeprecationWarning)
-
-
-class TestCurrentWidget(PlacelessSetup, unittest.TestCase):
-
-    _WidgetFactory = BrowserWidget
-
-    def setUp(self):
-        PlacelessSetup.setUp(self)
-        self._widget = BrowserWidget(Text(__name__='test'), TestRequest())
-        widget.warn = warn
-        browserwidget.warn = warn
-        global warnings
-        warnings = []
-
-    def test_haveInput(self):
-        self.assertEqual(len(warnings), 0)
-        self.failIf(self._widget.haveData())
-        self.assertEqual(len(warnings), 1)
-        self.assertEqual(warnings[0], DeprecationWarning)
-    
-    def test_getData(self):
-        self._widget.request.form['field.test'] = u'foo'
-        self.assertEqual(len(warnings), 0)
-        self.assertEqual(self._widget.getData(), u'foo')
-        self.assertEqual(len(warnings), 1)
-        self.assertEqual(warnings[0], DeprecationWarning)
-
-    def test_setData(self):
-        self.assertEqual(len(warnings), 0)
-        self._widget.setData('foo')
-        self.assertEqual(len(warnings), 1)
-        self.assertEqual(warnings[0], DeprecationWarning)
-
-        
-def test_suite():
-    return unittest.TestSuite((
-        unittest.makeSuite(TestOldWidget),
-        unittest.makeSuite(TestCurrentWidget)))
-
-if __name__=='__main__':
-    unittest.main(defaultTest='test_suite')
-
+##############################################################################
+#
+# 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.0 (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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+import unittest
+import random
+
+from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.app.browser.form.widget import BrowserWidget
+from zope.app.form import widget
+from zope.app.browser.form import widget as browserwidget
+from zope.publisher.browser import TestRequest
+from zope.schema import Text
+
+
+class OldWidget(BrowserWidget):
+    """Simulates a typical browser widget before the renaming of:
+    
+        getData -> getInputValue
+        setData -> setRenderedValue
+        haveData -> hasInput
+    """
+
+    def __init__(self, context, request):
+        super(OldWidget, self).__init__(context, request)
+        self._data = random.random() > 0.5 and u'foo' or None
+
+    def haveData(self):
+        return self._data is None
+
+    def getData(self):
+        return self._data
+
+
+warnings = []
+
+def warn(*args, **wk):
+    warnings.append(args[1]) # append the exception class
+
+
+class TestOldWidget(PlacelessSetup, unittest.TestCase):
+
+    def setUp(self):
+        super(TestOldWidget, self).setUp()
+        self._widget = OldWidget(Text(__name__='test'), TestRequest())
+        widget.warn = warn
+        browserwidget.warn = warn
+        global warnings
+        warnings = []
+
+    def test_haveInput(self):
+        self.assertEqual(self._widget.haveData(), self._widget.hasInput())
+    
+    def test_getData(self):
+        self.assertEqual(self._widget.getData(), self._widget.getInputValue())
+    
+    def test_setData(self):
+        self.assertEqual(len(warnings), 0)
+        self._widget.setData(u'bar')
+        self.assertEqual(self._widget.getInputValue(), u'bar')
+        self.assertEqual(len(warnings), 1)
+        self.assertEqual(warnings[0], DeprecationWarning)
+
+
+class TestCurrentWidget(PlacelessSetup, unittest.TestCase):
+
+    _WidgetFactory = BrowserWidget
+
+    def setUp(self):
+        super(TestCurrentWidget, self).setUp()
+        self._widget = BrowserWidget(Text(__name__='test'), TestRequest())
+        widget.warn = warn
+        browserwidget.warn = warn
+        global warnings
+        warnings = []
+
+    def test_haveInput(self):
+        self.assertEqual(len(warnings), 0)
+        self.failIf(self._widget.haveData())
+        self.assertEqual(len(warnings), 1)
+        self.assertEqual(warnings[0], DeprecationWarning)
+    
+    def test_getData(self):
+        self._widget.request.form['field.test'] = u'foo'
+        self.assertEqual(len(warnings), 0)
+        self.assertEqual(self._widget.getData(), u'foo')
+        self.assertEqual(len(warnings), 1)
+        self.assertEqual(warnings[0], DeprecationWarning)
+
+    def test_setData(self):
+        self.assertEqual(len(warnings), 0)
+        self._widget.setData('foo')
+        self.assertEqual(len(warnings), 1)
+        self.assertEqual(warnings[0], DeprecationWarning)
+
+        
+def test_suite():
+    return unittest.TestSuite((
+        unittest.makeSuite(TestOldWidget),
+        unittest.makeSuite(TestCurrentWidget)))
+
+if __name__=='__main__':
+    unittest.main(defaultTest='test_suite')
+




More information about the Zope3-Checkins mailing list