[Zope3-checkins] CVS: Zope3/src/zope/app/utilities/tests - test_schemautility.py:1.4

Sidnei da Silva sidnei at x3ng.com.br
Thu Sep 25 12:56:42 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/utilities/tests
In directory cvs.zope.org:/tmp/cvs-serv20978/src/zope/app/utilities/tests

Modified Files:
	test_schemautility.py 
Log Message:
Fixing the tests that I broke. setitem needs placefulSetup

=== Zope3/src/zope/app/utilities/tests/test_schemautility.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/utilities/tests/test_schemautility.py:1.3	Sun Aug 17 02:08:36 2003
+++ Zope3/src/zope/app/utilities/tests/test_schemautility.py	Thu Sep 25 12:56:42 2003
@@ -16,43 +16,46 @@
 """
 
 from unittest import TestCase, makeSuite, TestSuite
+
 from zope.app.utilities.schema import SchemaUtility
-from zope.schema import Text, getFieldsInOrder
+from zope.app.tests import setup
+from zope.schema import Text, getFieldNamesInOrder
 
 class SchemaUtilityTests(TestCase):
 
     def setUp(self):
+        setup.placefulSetUp()
         self.s = SchemaUtility()
         self.s.setName('IFoo')
         self.alpha = Text(title=u"alpha")
 
     def test_addField(self):
         s = self.s
-        s.addField('alpha', self.alpha)
+        s.addField(u'alpha', self.alpha)
         self.assertEquals(
-            [('alpha', self.alpha)],
-            getFieldsInOrder(s))
+            [u'alpha',],
+            getFieldNamesInOrder(s))
 
     def test_addFieldInsertsAtEnd(self):
         s = self.s
-        s.addField('alpha', self.alpha)
+        s.addField(u'alpha', self.alpha)
         beta = Text(title=u"Beta")
-        s.addField('beta', beta)
+        s.addField(u'beta', beta)
         self.assertEquals(
-            [('alpha', self.alpha),('beta', beta)],
-            getFieldsInOrder(s))
+            [u'alpha', u'beta'],
+            getFieldNamesInOrder(s))
 
     def test_removeField(self):
         s = self.s
-        s.addField('alpha', self.alpha)
-        s.removeField('alpha')
+        s.addField(u'alpha', self.alpha)
+        s.removeField(u'alpha')
         self.assertEquals(
             [],
-            getFieldsInOrder(s))
+            getFieldNamesInOrder(s))
 
     def test_addFieldCollision(self):
         s = self.s
-        s.addField('alpha', self.alpha)
+        s.addField(u'alpha', self.alpha)
         self.assertRaises(KeyError, s.addField, 'alpha', self.alpha)
 
     def test_removeFieldNotPresent(self):
@@ -60,16 +63,16 @@
 
     def test_renameField(self):
         s = self.s
-        s.addField('alpha', self.alpha)
-        s.renameField('alpha', 'beta')
+        s.addField(u'alpha', self.alpha)
+        s.renameField(u'alpha', 'beta')
         self.assertEquals(
-            [('beta', self.alpha)],
-            getFieldsInOrder(s))
+            [u'beta'],
+            getFieldNamesInOrder(s))
 
     def test_renameFieldCollision(self):
         s = self.s
-        s.addField('alpha', self.alpha)
-        s.addField('beta', Text(title=u"Beta"))
+        s.addField(u'alpha', self.alpha)
+        s.addField(u'beta', Text(title=u"Beta"))
         self.assertRaises(KeyError, s.renameField, 'alpha', 'beta')
 
     def test_renameFieldNotPresent(self):
@@ -77,17 +80,16 @@
 
     def test_insertField(self):
         s = self.s
-        s.addField('alpha', self.alpha)
+        s.addField(u'alpha', self.alpha)
         beta = Text(title=u"Beta")
-        s.insertField('beta', beta, 0)
+        s.insertField(u'beta', beta, 0)
         self.assertEquals(
-            [('beta', beta),
-             ('alpha', self.alpha)],
-            getFieldsInOrder(s))
+            [u'beta', u'alpha'],
+            getFieldNamesInOrder(s))
 
     def test_insertFieldCollision(self):
         s = self.s
-        s.addField('alpha', self.alpha)
+        s.addField(u'alpha', self.alpha)
         beta = Text(title=u"Beta")
         self.assertRaises(KeyError, s.insertField, 'alpha', beta, 0)
 
@@ -95,69 +97,66 @@
         s = self.s
         gamma = Text(title=u"Gamma")
         # it's still possible to insert at beginning
-        s.insertField('gamma', gamma, 0)
+        s.insertField(u'gamma', gamma, 0)
         self.assertEquals(
-            [('gamma', gamma)],
-            getFieldsInOrder(s))
+            [u'gamma'],
+            getFieldNamesInOrder(s))
         # should be allowed to insert field at the end
-        s.insertField('alpha', self.alpha, 1)
+        s.insertField(u'alpha', self.alpha, 1)
         self.assertEquals(
-            [('gamma', gamma),
-             ('alpha', self.alpha)],
-            getFieldsInOrder(s))
+            [u'gamma', u'alpha'],
+            getFieldNamesInOrder(s))
         # should be allowed to insert field at the beginning still
         delta = Text(title=u"Delta")
-        s.insertField('delta', delta, 0)
+        s.insertField(u'delta', delta, 0)
         self.assertEquals(
-            [('delta', delta),
-             ('gamma', gamma),
-             ('alpha', self.alpha)],
-            getFieldsInOrder(s))
+            [u'delta', u'gamma', u'alpha'],
+            getFieldNamesInOrder(s))
 
     def test_insertFieldBeyondEnd(self):
         s = self.s
-        s.addField('alpha', self.alpha)
+        s.addField(u'alpha', self.alpha)
         beta = Text(title=u"Beta")
         self.assertRaises(IndexError, s.insertField,
                           'beta', beta, 100)
 
     def test_insertFieldBeforeBeginning(self):
         s = self.s
-        s.addField('alpha', self.alpha)
+        s.addField(u'alpha', self.alpha)
         beta = Text(title=u"Beta")
         self.assertRaises(IndexError, s.insertField,
                           'beta', beta, -1)
 
     def test_moveField(self):
         s = self.s
-        s.addField('alpha', self.alpha)
+        s.addField(u'alpha', self.alpha)
         beta = Text(title=u'Beta')
-        s.addField('beta', beta)
+        s.addField(u'beta', beta)
         gamma = Text(title=u'Gamma')
-        s.addField('gamma', gamma)
-        s.moveField('beta', 3)
+        s.addField(u'gamma', gamma)
+        s.moveField(u'beta', 3)
         self.assertEquals(
-            [('alpha', self.alpha),
-             ('gamma', gamma),
-             ('beta', beta)],
-            getFieldsInOrder(s))
+            [u'alpha', u'gamma', u'beta'],
+            getFieldNamesInOrder(s))
 
     def test_moveFieldBeyondEnd(self):
         s = self.s
-        s.addField('alpha', self.alpha)
+        s.addField(u'alpha', self.alpha)
         beta = Text(title=u"Beta")
-        s.addField('beta', beta)
+        s.addField(u'beta', beta)
         self.assertRaises(IndexError, s.moveField,
                           'beta', 100)
 
     def test_moveFieldBeforeBeginning(self):
         s = self.s
-        s.addField('alpha', self.alpha)
+        s.addField(u'alpha', self.alpha)
         beta = Text(title=u"Beta")
-        s.addField('beta', beta)
+        s.addField(u'beta', beta)
         self.assertRaises(IndexError, s.moveField,
                           'beta', -1)
 
+    def tearDown(self):
+        setup.placefulTearDown()
 
 def test_suite():
     return TestSuite(




More information about the Zope3-Checkins mailing list