[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Forms/Views/Browser/tests - testBrowserWidget.py:1.6

Jim Fulton jim@zope.com
Wed, 4 Dec 2002 04:58:47 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Forms/Views/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv13281/Views/Browser/tests

Modified Files:
	testBrowserWidget.py 
Log Message:
Fixed a bug in handling of conversions when getting data to be
inserted into forms.


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testBrowserWidget.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testBrowserWidget.py:1.5	Mon Nov 11 15:43:33 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testBrowserWidget.py	Wed Dec  4 04:58:46 2002
@@ -72,10 +72,31 @@
         value = ''.join(self._widget().strip().split())
         row = ''.join(self._widget.row().strip().split())
         self.assertEqual(row, '<td>%s</td><td>%s</td>' % (label, value))
-        
+
+class Test(BrowserWidgetTest):
+
+    def test_showData(self):
+
+        class W(BrowserWidget):
+            def _convert(self, v):
+                return u'X' + (v or '')
+
+            def _unconvert(self, v):
+                return v and v[1:] or ''
+
+        field = Text(__name__ = 'foo', title = u"Foo Title")
+        request = TestRequest()
+
+        w = W(field, request)
+        self.assertEqual(w._showData(), '')
+        request.form['field.foo'] = 'val'
+        self.assertEqual(w._showData(), 'val')
+
+        w.setData('Xfoo')
+        self.assertEqual(w._showData(), 'foo')        
 
 def test_suite():
-    return unittest.makeSuite(BrowserWidgetTest)
+    return unittest.makeSuite(Test)
 
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')