[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests -
test_browserwidget.py:1.20 test_checkboxwidget.py:1.10
test_datetimewidget.py:1.3 test_datewidget.py:1.3
test_directives.py:1.5 test_editview.py:1.19
test_editwizardview.py:1.2 test_filewidget.py:1.8
test_floatwidget.py:1.3 test_intwidget.py:1.3
test_listwidget.py:1.9 test_multicheckboxwidget.py:1.9
test_multilistwidget.py:1.9 test_objectwidget.py:1.6
test_passwordwidget.py:1.9 test_radiowidget.py:1.11
test_sequencewidget.py:1.7 test_textareawidget.py:1.10
test_textwidget.py:1.8 test_widget_deprecations.py:NONE
Garrett Smith
garrett at mojave-corp.com
Fri Mar 5 23:17:50 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv15646/src/zope/app/browser/form/tests
Modified Files:
test_browserwidget.py test_checkboxwidget.py
test_datetimewidget.py test_datewidget.py test_directives.py
test_editview.py test_editwizardview.py test_filewidget.py
test_floatwidget.py test_intwidget.py test_listwidget.py
test_multicheckboxwidget.py test_multilistwidget.py
test_objectwidget.py test_passwordwidget.py
test_radiowidget.py test_sequencewidget.py
test_textareawidget.py test_textwidget.py
Removed Files:
test_widget_deprecations.py
Log Message:
Merged changes from garrett-widgets2-branch:
- Changed the way widgets are looked up to use interfaces instead of
names.
- Refactor of zope/app/form/utility.py -- see
http://dev.zope.org/Zope3/WidgetsAndMultiwayAdapters
for details.
- Moved configuration of vocab widgets to its own zcml file
(zope/app/browser/form/vocabularywidget.zcml).
- Removed 'propertyNames' and 'getValue' from widgets. This is replaced
by accessing the widget attributes directly.
- Deleted depreated methods from widget interface: haveData and getData.
=== Zope3/src/zope/app/browser/form/tests/test_browserwidget.py 1.19 => 1.20 ===
--- Zope3/src/zope/app/browser/form/tests/test_browserwidget.py:1.19 Tue Jan 20 15:15:26 2004
+++ Zope3/src/zope/app/browser/form/tests/test_browserwidget.py Fri Mar 5 23:17:18 2004
@@ -68,10 +68,10 @@
self.failIf(self._widget.hasInput())
def testProperties(self):
- self.assertEqual(self._widget.getValue('tag'), 'input')
- self.assertEqual(self._widget.getValue('type'), 'text')
- self.assertEqual(self._widget.getValue('cssClass'), '')
- self.assertEqual(self._widget.getValue('extra'), '')
+ self.assertEqual(self._widget.tag, 'input')
+ self.assertEqual(self._widget.type, 'text')
+ self.assertEqual(self._widget.cssClass, '')
+ self.assertEqual(self._widget.extra, '')
def testRender(self):
value = 'Foo Value'
=== Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py:1.9 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py Fri Mar 5 23:17:18 2004
@@ -14,25 +14,106 @@
"""
$Id$
"""
-import unittest
+import unittest, doctest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import CheckBoxWidget
+from zope.publisher.browser import TestRequest
from zope.schema import Bool
+from zope.interface.verify import verifyClass
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
class CheckBoxWidgetTest(BrowserWidgetTest):
+ """Documents and tests thec checkbox widget.
+
+ >>> verifyClass(IInputWidget, CheckBoxWidget)
+ True
+
+ The rest of the this doctest was moved from widget.py to this test module
+ to keep widget.py free of detailed tests. XXX the tests below should be
+ more narrative to highlight the 'story' being told.
+
+ >>> field = Bool(__name__='foo', title=u'on')
+ >>> request = TestRequest(form={'field.foo.used': u'on',
+ ... 'field.foo': u'on'})
+ >>> widget = CheckBoxWidget(field, request)
+ >>> widget.hasInput()
+ True
+ >>> widget.getInputValue()
+ True
+
+ >>> def normalize(s):
+ ... return '\\n '.join(s.split())
+
+ >>> print normalize( widget() )
+ <input
+ class="hiddenType"
+ id="field.foo.used"
+ name="field.foo.used"
+ type="hidden"
+ value=""
+ />
+ <input
+ class="checkboxType"
+ checked="checked"
+ id="field.foo"
+ name="field.foo"
+ type="checkbox"
+ />
+
+ >>> print normalize( widget.hidden() )
+ <input
+ class="hiddenType"
+ id="field.foo"
+ name="field.foo"
+ type="hidden"
+ value="on"
+ />
+
+ Calling setRenderedValue will change what gets output:
+
+ >>> widget.setRenderedValue(False)
+ >>> print normalize( widget() )
+ <input
+ class="hiddenType"
+ id="field.foo.used"
+ name="field.foo.used"
+ type="hidden"
+ value=""
+ />
+ <input
+ class="checkboxType"
+ id="field.foo"
+ name="field.foo"
+ type="checkbox"
+ />
+
+ When a checkbox is not 'checked', it's value is not
+ sent in the request, so we consider it 'False', which
+ means that 'required' for a boolean field doesn't make
+ much sense in the end.
+
+ >>> field = Bool(__name__='foo', title=u'on', required=True)
+ >>> request = TestRequest(form={'field.foo.used': u''})
+ >>> widget = CheckBoxWidget(field, request)
+ >>> widget.hasInput()
+ True
+ >>> widget.validate()
+ >>> widget.getInputValue()
+ False
+ """
_FieldFactory = Bool
_WidgetFactory = CheckBoxWidget
def testProperties(self):
- self.assertEqual(self._widget.getValue('tag'), 'input')
- self.assertEqual(self._widget.getValue('type'), 'checkbox')
- self.assertEqual(self._widget.getValue('cssClass'), '')
- self.assertEqual(self._widget.getValue('extra'), '')
- self.assertEqual(self._widget.getValue('default'), 0)
+ self.assertEqual(self._widget.tag, 'input')
+ self.assertEqual(self._widget.type, 'checkbox')
+ self.assertEqual(self._widget.cssClass, '')
+ self.assertEqual(self._widget.extra, '')
+ self.assertEqual(self._widget.default, 0)
def testRender(self):
value = 1
@@ -60,7 +141,10 @@
def test_suite():
- return unittest.makeSuite(CheckBoxWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(CheckBoxWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_datetimewidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/form/tests/test_datetimewidget.py:1.2 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_datetimewidget.py Fri Mar 5 23:17:18 2004
@@ -14,15 +14,23 @@
"""
$Id$
"""
-from unittest import main, makeSuite
+import unittest, doctest
from zope.app.datetimeutils import parseDatetimetz
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import DatetimeWidget
from zope.app.interfaces.form import ConversionError, WidgetInputError
+from zope.interface.verify import verifyClass
+
from zope.schema import Datetime
class DatetimeWidgetTest(BrowserWidgetTest):
+ """Documents and tests the datetime widget.
+
+ >>> verifyClass(IInputWidget, DatetimeWidget)
+ True
+ """
_FieldFactory = Datetime
_WidgetFactory = DatetimeWidget
@@ -47,8 +55,11 @@
def test_suite():
- return makeSuite(DatetimeWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(DatetimeWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_datewidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/form/tests/test_datewidget.py:1.2 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_datewidget.py Fri Mar 5 23:17:18 2004
@@ -14,15 +14,21 @@
"""
$Id$
"""
-from unittest import main, makeSuite
+import unittest, doctest
from zope.app.datetimeutils import parseDatetimetz
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import DateWidget
from zope.app.interfaces.form import ConversionError, WidgetInputError
from zope.schema import Date
-
+from zope.interface.verify import verifyClass
class DateWidgetTest(BrowserWidgetTest):
+ """Documents and tests the date widget.
+
+ >>> verifyClass(IInputWidget, DateWidget)
+ True
+ """
_FieldFactory = Date
_WidgetFactory = DateWidget
@@ -48,8 +54,11 @@
def test_suite():
- return makeSuite(DateWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(DateWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_directives.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/form/tests/test_directives.py:1.4 Tue Mar 2 13:27:38 2004
+++ Zope3/src/zope/app/browser/form/tests/test_directives.py Fri Mar 5 23:17:18 2004
@@ -1,4 +1,4 @@
-###########################################################IC#############
+#############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
@@ -66,12 +66,11 @@
ob = Ob()
-
-
class Test(PlacelessSetup, unittest.TestCase):
def setUp(self):
super(Test, self).setUp()
+ XMLConfig('meta.zcml', zope.app.component)()
XMLConfig('meta.zcml', zope.app.browser.form)()
XMLConfig('meta.zcml', zope.app.publisher.browser)()
@@ -88,24 +87,23 @@
def testEditForm(self):
self.assertEqual(queryView(ob, 'test', request),
None)
- xmlconfig(StringIO(template % (
- """
- <browser:page
- permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.ITextLine"
- name="edit"
- class="zope.app.browser.form.widget.TextWidget"
- />
- <browser:editform
- for="zope.app.browser.form.tests.test_directives.IC"
- schema="zope.app.browser.form.tests.test_directives.Schema"
- name="edit.html"
- label="Edit a ZPT page"
- fields="text"
- permission="zope.Public" />
- """
- )))
+ xmlconfig(StringIO(template % ("""
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.ITextLine"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.TextWidget"
+ permission="zope.Public"
+ />
+
+ <browser:editform
+ for="zope.app.browser.form.tests.test_directives.IC"
+ schema="zope.app.browser.form.tests.test_directives.Schema"
+ name="edit.html"
+ label="Edit a ZPT page"
+ fields="text"
+ permission="zope.Public" />
+ """)))
v = queryView(ob, 'edit.html', request)
# expect component lookup as standard macros are not configured
@@ -115,28 +113,26 @@
def testEditFormWithMenu(self):
self.assertEqual(queryView(ob, 'test', request),
None)
- xmlconfig(StringIO(template % (
- """
- <browser:menu id="test_menu" title="Test menu" usage="objectview"/>
- <browser:page
- permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.ITextLine"
- name="edit"
- class="zope.app.browser.form.widget.TextWidget"
- />
- <browser:editform
- for="zope.app.browser.form.tests.test_directives.IC"
- schema="zope.app.browser.form.tests.test_directives.Schema"
- name="edit.html"
- label="Edit a ZPT page"
- fields="text"
- permission="zope.Public"
- menu="test_menu"
- title="Test View"
- />
- """
- )))
+ xmlconfig(StringIO(template % ("""
+ <browser:menu id="test_menu" title="Test menu" usage="objectview"/>
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.ITextLine"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.TextWidget"
+ permission="zope.Public"
+ />
+ <browser:editform
+ for="zope.app.browser.form.tests.test_directives.IC"
+ schema="zope.app.browser.form.tests.test_directives.Schema"
+ name="edit.html"
+ label="Edit a ZPT page"
+ fields="text"
+ permission="zope.Public"
+ menu="test_menu"
+ title="Test View"
+ />
+ """)))
v = queryView(ob, 'edit.html', request)
self.assertEqual(v.usage, 'objectview')
@@ -146,26 +142,24 @@
def testEditFormWithUsage(self):
self.assertEqual(queryView(ob, 'test', request),
None)
- xmlconfig(StringIO(template % (
- """
- <browser:page
- permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.ITextLine"
- name="edit"
- class="zope.app.browser.form.widget.TextWidget"
- />
- <browser:editform
- for="zope.app.browser.form.tests.test_directives.IC"
- schema="zope.app.browser.form.tests.test_directives.Schema"
- name="edit.html"
- label="Edit a ZPT page"
- fields="text"
- permission="zope.Public"
- usage="objectview"
- />
- """
- )))
+ xmlconfig(StringIO(template % ("""
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.ITextLine"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.TextWidget"
+ permission="zope.Public"
+ />
+ <browser:editform
+ for="zope.app.browser.form.tests.test_directives.IC"
+ schema="zope.app.browser.form.tests.test_directives.Schema"
+ name="edit.html"
+ label="Edit a ZPT page"
+ fields="text"
+ permission="zope.Public"
+ usage="objectview"
+ />
+ """)))
v = queryView(ob, 'edit.html', request)
self.assertEqual(v.usage, 'objectview')
@@ -176,29 +170,27 @@
def testEditFormWithMenuAndUsage(self):
self.assertEqual(queryView(ob, 'test', request),
None)
- xmlconfig(StringIO(template % (
- """
- <browser:menu id="test_menu" title="Test menu" usage="overridden"/>
- <browser:page
- permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.ITextLine"
- name="edit"
- class="zope.app.browser.form.widget.TextWidget"
- />
- <browser:editform
- for="zope.app.browser.form.tests.test_directives.IC"
- schema="zope.app.browser.form.tests.test_directives.Schema"
- name="edit.html"
- label="Edit a ZPT page"
- fields="text"
- permission="zope.Public"
- menu="test_menu"
- title="Test View"
- usage="objectview"
- />
- """
- )))
+ xmlconfig(StringIO(template % ("""
+ <browser:menu id="test_menu" title="Test menu" usage="overridden"/>
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.ITextLine"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.TextWidget"
+ permission="zope.Public"
+ />
+ <browser:editform
+ for="zope.app.browser.form.tests.test_directives.IC"
+ schema="zope.app.browser.form.tests.test_directives.Schema"
+ name="edit.html"
+ label="Edit a ZPT page"
+ fields="text"
+ permission="zope.Public"
+ menu="test_menu"
+ title="Test View"
+ usage="objectview"
+ />
+ """)))
v = queryView(ob, 'edit.html', request)
self.assertEqual(v.usage, 'objectview')
=== Zope3/src/zope/app/browser/form/tests/test_editview.py 1.18 => 1.19 ===
--- Zope3/src/zope/app/browser/form/tests/test_editview.py:1.18 Thu Feb 26 05:28:41 2004
+++ Zope3/src/zope/app/browser/form/tests/test_editview.py Fri Mar 5 23:17:18 2004
@@ -28,7 +28,8 @@
from zope.app.browser.form.editview import EditView
from zope.app.browser.form.widget import TextWidget
from zope.app.browser.form.submit import Update
-
+from zope.component.exceptions import ComponentLookupError
+from zope.app.interfaces.form import IInputWidget
class I(Interface):
foo = TextLine(title=u"Foo")
@@ -102,8 +103,7 @@
def setUp(self):
super(Test, self).setUp()
- ztapi.browserView(ITextLine, 'edit', TextWidget)
- ztapi.setDefaultViewName(ITextLine, "edit")
+ ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
ztapi.provideAdapter(IFoo, IBar, FooBarAdapter)
def test_setPrefix_and_widgets(self):
=== Zope3/src/zope/app/browser/form/tests/test_editwizardview.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/form/tests/test_editwizardview.py:1.1 Thu Feb 26 05:28:41 2004
+++ Zope3/src/zope/app/browser/form/tests/test_editwizardview.py Fri Mar 5 23:17:19 2004
@@ -27,6 +27,8 @@
from zope.app.browser.form.editwizard import EditWizardView
from zope.app.browser.form.widget import TextWidget
+from zope.app.interfaces.form import IInputWidget
+
class I(Interface):
foo = TextLine(title=u"Foo")
@@ -99,8 +101,7 @@
def setUp(self):
super(Test, self).setUp()
- ztapi.browserView(ITextLine, 'edit', TextWidget)
- ztapi.setDefaultViewName(ITextLine, "edit")
+ ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
ztapi.provideAdapter(IFoo, IBar, FooBarAdapter)
def test_setUpWidget(self):
=== Zope3/src/zope/app/browser/form/tests/test_filewidget.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/form/tests/test_filewidget.py:1.7 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_filewidget.py Fri Mar 5 23:17:19 2004
@@ -14,14 +14,22 @@
"""
$Id$
"""
-import unittest
+import unittest, doctest
from StringIO import StringIO
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import FileWidget
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.interface.verify import verifyClass
+
class FileWidgetTest(BrowserWidgetTest):
+ """Documents and tests the file widget.
+
+ >>> verifyClass(IInputWidget, FileWidget)
+ True
+ """
_WidgetFactory = FileWidget
@@ -33,13 +41,13 @@
self._widget.request.form['field.foo'] = file
def testProperties(self):
- self.assertEqual(self._widget.getValue('tag'), 'input')
- self.assertEqual(self._widget.getValue('type'), 'file')
- self.assertEqual(self._widget.getValue('cssClass'), '')
- self.assertEqual(self._widget.getValue('extra'), '')
- self.assertEqual(self._widget.getValue('default'), '')
- self.assertEqual(self._widget.getValue('displayWidth'), 20)
- self.assertEqual(self._widget.getValue('displayMaxWidth'), '')
+ self.assertEqual(self._widget.tag, 'input')
+ self.assertEqual(self._widget.type, 'file')
+ self.assertEqual(self._widget.cssClass, '')
+ self.assertEqual(self._widget.extra, '')
+ self.assertEqual(self._widget.default, '')
+ self.assertEqual(self._widget.displayWidth, 20)
+ self.assertEqual(self._widget.displayMaxWidth, '')
def testRender(self):
value = 'Foo Value'
@@ -57,7 +65,10 @@
def test_suite():
- return unittest.makeSuite(FileWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(FileWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_floatwidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/form/tests/test_floatwidget.py:1.2 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_floatwidget.py Fri Mar 5 23:17:19 2004
@@ -14,14 +14,22 @@
"""
$Id$
"""
-from unittest import main, makeSuite
+import unittest, doctest
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import FloatWidget
from zope.app.interfaces.form import ConversionError, WidgetInputError
+from zope.interface.verify import verifyClass
+
from zope.schema import Float
class FloatWidgetTest(BrowserWidgetTest):
+ """Documents and tests the float widget.
+
+ >>> verifyClass(IInputWidget, FloatWidget)
+ True
+ """
_FieldFactory = Float
_WidgetFactory = FloatWidget
@@ -45,7 +53,10 @@
def test_suite():
- return makeSuite(FloatWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(FloatWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_intwidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/form/tests/test_intwidget.py:1.2 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_intwidget.py Fri Mar 5 23:17:19 2004
@@ -14,14 +14,23 @@
"""
$Id$
"""
+import unittest, doctest
from unittest import main, makeSuite
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import IntWidget
from zope.app.interfaces.form import ConversionError, WidgetInputError
+from zope.interface.verify import verifyClass
+
from zope.schema import Int
class IntWidgetTest(BrowserWidgetTest):
+ """Documents and tests the int widget.
+
+ >>> verifyClass(IInputWidget, IntWidget)
+ True
+ """
_FieldFactory = Int
_WidgetFactory = IntWidget
@@ -45,7 +54,10 @@
def test_suite():
- return makeSuite(IntWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(IntWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_listwidget.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/form/tests/test_listwidget.py:1.8 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_listwidget.py Fri Mar 5 23:17:19 2004
@@ -14,12 +14,19 @@
"""
$Id$
"""
-import unittest
+import unittest, doctest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import ListWidget
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.interface.verify import verifyClass
class ListWidgetTest(BrowserWidgetTest):
+ """Documents and tests the list widget.
+
+ >>> verifyClass(IInputWidget, ListWidget)
+ True
+ """
def setUp(self):
BrowserWidgetTest.setUp(self)
@@ -28,10 +35,10 @@
_WidgetFactory = ListWidget
def testProperties(self):
- self.assertEqual(self._widget.getValue('cssClass'), "")
- self.assertEqual(self._widget.getValue('extra'), '')
- self.assertEqual(self._widget.getValue('firstItem'), 0)
- self.assertEqual(self._widget.getValue('size'), 5)
+ self.assertEqual(self._widget.cssClass, "")
+ self.assertEqual(self._widget.extra, '')
+ self.assertEqual(self._widget.firstItem, 0)
+ self.assertEqual(self._widget.size, 5)
def testRenderItem(self):
@@ -71,7 +78,10 @@
def test_suite():
- return unittest.makeSuite(ListWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(ListWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py:1.8 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py Fri Mar 5 23:17:19 2004
@@ -14,12 +14,19 @@
"""
$Id$
"""
-import unittest
+import unittest, doctest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import MultiCheckBoxWidget
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.interface.verify import verifyClass
class MultiCheckBoxWidgetTest(BrowserWidgetTest):
+ """Documents and tests the multi checkbox widget.
+
+ >>> verifyClass(IInputWidget, MultiCheckBoxWidget)
+ True
+ """
_WidgetFactory = MultiCheckBoxWidget
@@ -28,9 +35,9 @@
self._widget.context.allowed_values = (u'foo', u'bar')
def testProperties(self):
- self.assertEqual(self._widget.getValue('cssClass'), "")
- self.assertEqual(self._widget.getValue('extra'), '')
- self.assertEqual(self._widget.getValue('orientation'), 'vertical')
+ self.assertEqual(self._widget.cssClass, "")
+ self.assertEqual(self._widget.extra, '')
+ self.assertEqual(self._widget.orientation, 'vertical')
def testRenderItem(self):
@@ -71,7 +78,10 @@
def test_suite():
- return unittest.makeSuite(MultiCheckBoxWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(MultiCheckBoxWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py:1.8 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py Fri Mar 5 23:17:19 2004
@@ -14,12 +14,19 @@
"""
$Id$
"""
-import unittest
+import unittest, doctest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import MultiListWidget
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.interface.verify import verifyClass
class MultiListWidgetTest(BrowserWidgetTest):
+ """Documents and tests the multi-list widget.
+
+ >>> verifyClass(IInputWidget, MultiListWidget)
+ True
+ """
_WidgetFactory = MultiListWidget
@@ -28,9 +35,9 @@
self._widget.context.allowed_values = (u'foo', u'bar')
def testProperties(self):
- self.assertEqual(self._widget.getValue('cssClass'), "")
- self.assertEqual(self._widget.getValue('extra'), '')
- self.assertEqual(self._widget.getValue('size'), 5)
+ self.assertEqual(self._widget.cssClass, "")
+ self.assertEqual(self._widget.extra, '')
+ self.assertEqual(self._widget.size, 5)
def testRenderItem(self):
@@ -70,7 +77,10 @@
def test_suite():
- return unittest.makeSuite(MultiListWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(MultiListWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_objectwidget.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/browser/form/tests/test_objectwidget.py:1.5 Fri Nov 21 12:11:56 2003
+++ Zope3/src/zope/app/browser/form/tests/test_objectwidget.py Fri Mar 5 23:17:19 2004
@@ -15,14 +15,16 @@
$Id$
"""
-import unittest
+import unittest, doctest
from zope.app.tests import ztapi
from zope.interface import Interface, implements
from zope.schema.interfaces import ITextLine
from zope.publisher.browser import TestRequest
from zope.schema import Object, TextLine
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import TextWidget, ObjectWidget
+from zope.interface.verify import verifyClass
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
@@ -33,13 +35,19 @@
implements(ITestContact)
class ObjectWidgetTest(BrowserWidgetTest):
+ """Documents and tests the object widget.
+
+ >>> verifyClass(IInputWidget, ObjectWidget)
+ True
+ """
+
_FieldFactory = Object
def _WidgetFactory(self, context, request, **kw):
kw.update({'factory': TestContact})
return ObjectWidget(context, request, **kw)
def setUpContent(self, desc=u''):
- ztapi.browserView(ITextLine, 'edit', TextWidget)
+ ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
class ITestContent(Interface):
foo = self._FieldFactory(
@@ -67,7 +75,7 @@
def setUp(self):
BrowserWidgetTest.setUp(self)
self.field = Object(ITestContact, __name__=u'foo')
- ztapi.browserView(ITextLine, 'edit', [TextWidget])
+ ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
def test_applyChanges(self):
self.request.form['field.foo.name'] = u'Foo Name'
@@ -124,7 +132,10 @@
self.verifyResult(widget(), check_list)
def test_suite():
- return unittest.makeSuite(ObjectWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(ObjectWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py:1.8 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py Fri Mar 5 23:17:19 2004
@@ -14,24 +14,30 @@
"""
$Id$
"""
-import unittest
+import unittest, doctest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import PasswordWidget
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
-
+from zope.interface.verify import verifyClass
class PasswordWidgetTest(BrowserWidgetTest):
+ """Documents and tests the password widget.
+
+ >>> verifyClass(IInputWidget, PasswordWidget)
+ True
+ """
_WidgetFactory = PasswordWidget
def testProperties(self):
- self.assertEqual(self._widget.getValue('tag'), 'input')
- self.assertEqual(self._widget.getValue('type'), 'password')
- self.assertEqual(self._widget.getValue('cssClass'), '')
- self.assertEqual(self._widget.getValue('extra'), '')
- self.assertEqual(self._widget.getValue('default'), '')
- self.assertEqual(self._widget.getValue('displayWidth'), 20)
- self.assertEqual(self._widget.getValue('displayMaxWidth'), '')
+ self.assertEqual(self._widget.tag, 'input')
+ self.assertEqual(self._widget.type, 'password')
+ self.assertEqual(self._widget.cssClass, '')
+ self.assertEqual(self._widget.extra, '')
+ self.assertEqual(self._widget.default, '')
+ self.assertEqual(self._widget.displayWidth, 20)
+ self.assertEqual(self._widget.displayMaxWidth, '')
def testRender(self):
value = 'Foo Value'
@@ -44,7 +50,10 @@
self.assertRaises(NotImplementedError, self._widget.hidden)
def test_suite():
- return unittest.makeSuite(PasswordWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(PasswordWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_radiowidget.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/browser/form/tests/test_radiowidget.py:1.10 Sat Aug 16 13:23:37 2003
+++ Zope3/src/zope/app/browser/form/tests/test_radiowidget.py Fri Mar 5 23:17:19 2004
@@ -14,12 +14,19 @@
"""
$Id$
"""
-import unittest
+import unittest, doctest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import RadioWidget
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.interface.verify import verifyClass
class RadioWidgetTest(BrowserWidgetTest):
+ """Documents and tests the radio widget.
+
+ >>> verifyClass(IInputWidget, RadioWidget)
+ True
+ """
_WidgetFactory = RadioWidget
@@ -28,10 +35,10 @@
self._widget.context.allowed_values = (u'foo', u'bar')
def testProperties(self):
- self.assertEqual(self._widget.getValue('cssClass'), "")
- self.assertEqual(self._widget.getValue('extra'), '')
- self.assertEqual(self._widget.getValue('firstItem'), 0)
- self.assertEqual(self._widget.getValue('orientation'), 'vertical')
+ self.assertEqual(self._widget.cssClass, "")
+ self.assertEqual(self._widget.extra, '')
+ self.assertEqual(self._widget.firstItem, 0)
+ self.assertEqual(self._widget.orientation, 'vertical')
def testRenderItem(self):
@@ -117,7 +124,10 @@
'</div>' % (id, label, id, value))
def test_suite():
- return unittest.makeSuite(RadioWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(RadioWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py:1.6 Mon Jan 5 06:24:58 2004
+++ Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py Fri Mar 5 23:17:19 2004
@@ -15,22 +15,33 @@
$Id$
"""
-import unittest
+import unittest, doctest
from zope.app.tests import ztapi
from zope.app.browser.form.widget import TextWidget
from zope.schema.interfaces import ITextLine, ValidationError
from zope.publisher.browser import TestRequest
from zope.schema import Tuple, List, TextLine
-from zope.app.browser.form.widget import TupleSequenceWidget, \
- ListSequenceWidget
-
+from zope.app.interfaces.form import IInputWidget
+from zope.app.browser.form.widget import TupleSequenceWidget
+from zope.app.browser.form.widget import ListSequenceWidget
+from zope.interface.verify import verifyClass
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
class SequenceWidgetTest(BrowserWidgetTest):
+ """Documents and tests the tuple and list (sequence) widgets.
+
+ >>> verifyClass(IInputWidget, TupleSequenceWidget)
+ True
+ >>> verifyClass(IInputWidget, ListSequenceWidget)
+ True
+ """
+
def _FieldFactory(self, **kw):
- kw.update({'__name__': u'foo', 'value_type': TextLine(__name__=u'bar')})
+ kw.update({
+ '__name__': u'foo',
+ 'value_type': TextLine(__name__=u'bar')})
return Tuple(**kw)
_WidgetFactory = TupleSequenceWidget
@@ -39,9 +50,10 @@
def setUp(self):
BrowserWidgetTest.setUp(self)
- self.field = Tuple(__name__=u'foo',
+ self.field = Tuple(
+ __name__=u'foo',
value_type=TextLine(__name__=u'bar'))
- ztapi.browserView(ITextLine, 'edit', TextWidget)
+ ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
def test_haveNoData(self):
self.failIf(self._widget.hasInput())
@@ -51,7 +63,9 @@
self.failUnless(self._widget.hasInput())
def test_list(self):
- self.field = List(__name__=u'foo', value_type=TextLine(__name__=u'bar'))
+ self.field = List(
+ __name__=u'foo',
+ value_type=TextLine(__name__=u'bar'))
request = TestRequest()
widget = ListSequenceWidget(self.field, request)
self.failIf(widget.hasInput())
@@ -167,7 +181,10 @@
self.verifyResult(s, check_list, inorder=True)
def test_suite():
- return unittest.makeSuite(SequenceWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(SequenceWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_textareawidget.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/browser/form/tests/test_textareawidget.py:1.9 Sat Aug 16 13:23:37 2003
+++ Zope3/src/zope/app/browser/form/tests/test_textareawidget.py Fri Mar 5 23:17:19 2004
@@ -14,23 +14,29 @@
"""
$Id$
"""
-import unittest
+import unittest, doctest
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import TextAreaWidget
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
-
+from zope.interface.verify import verifyClass
class TextAreaWidgetTest(BrowserWidgetTest):
+ """Documents and tests the text area widget.
+
+ >>> verifyClass(IInputWidget, TextAreaWidget)
+ True
+ """
_WidgetFactory = TextAreaWidget
def testProperties(self):
- self.assertEqual(self._widget.getValue('tag'), 'input')
- self.assertEqual(self._widget.getValue('type'), 'text')
- self.assertEqual(self._widget.getValue('cssClass'), '')
- self.assertEqual(self._widget.getValue('extra'), '')
- self.assertEqual(self._widget.getValue('width'), 60)
- self.assertEqual(self._widget.getValue('height'), 15)
+ self.assertEqual(self._widget.tag, 'input')
+ self.assertEqual(self._widget.type, 'text')
+ self.assertEqual(self._widget.cssClass, '')
+ self.assertEqual(self._widget.extra, '')
+ self.assertEqual(self._widget.width, 60)
+ self.assertEqual(self._widget.height, 15)
def testRender(self):
value = "Foo Value"
@@ -47,7 +53,10 @@
def test_suite():
- return unittest.makeSuite(TextAreaWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(TextAreaWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_textwidget.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/form/tests/test_textwidget.py:1.7 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_textwidget.py Fri Mar 5 23:17:19 2004
@@ -14,24 +14,32 @@
"""
$Id$
"""
-import unittest
+import unittest, doctest
+from zope.interface.verify import verifyClass
+from zope.schema import TextLine
+
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.form.widget import TextWidget
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
-
class TextWidgetTest(BrowserWidgetTest):
+ """Documents and tests the text widget.
+
+ >>> verifyClass(IInputWidget, TextWidget)
+ True
+ """
_WidgetFactory = TextWidget
def testProperties(self):
- self.assertEqual(self._widget.getValue('tag'), 'input')
- self.assertEqual(self._widget.getValue('type'), 'text')
- self.assertEqual(self._widget.getValue('cssClass'), '')
- self.assertEqual(self._widget.getValue('extra'), '')
- self.assertEqual(self._widget.getValue('default'), '')
- self.assertEqual(self._widget.getValue('displayWidth'), 20)
- self.assertEqual(self._widget.getValue('displayMaxWidth'), '')
+ self.assertEqual(self._widget.tag, 'input')
+ self.assertEqual(self._widget.type, 'text')
+ self.assertEqual(self._widget.cssClass, '')
+ self.assertEqual(self._widget.extra, '')
+ self.assertEqual(self._widget.default, '')
+ self.assertEqual(self._widget.displayWidth, 20)
+ self.assertEqual(self._widget.displayMaxWidth, '')
def testRender(self):
value = 'Foo Value'
@@ -45,10 +53,11 @@
self._widget.extra = 'style="color: red"'
self.verifyResult(self._widget.hidden(), check_list)
-
-
def test_suite():
- return unittest.makeSuite(TextWidgetTest)
+ return unittest.TestSuite((
+ unittest.makeSuite(TextWidgetTest),
+ doctest.DocTestSuite(),
+ ))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Removed File Zope3/src/zope/app/browser/form/tests/test_widget_deprecations.py ===
More information about the Zope3-Checkins
mailing list