[Zope3-checkins] CVS: Zope3/src/zope/schema/tests - states.py:1.3 tabcomplete.py:1.3 test_accessors.py:1.3 test_states.py:1.3 test_vocabulary.py:1.7

Steve Alexander steve@cat-box.net
Wed, 4 Jun 2003 05:10:17 -0400


Update of /cvs-repository/Zope3/src/zope/schema/tests
In directory cvs.zope.org:/tmp/cvs-serv26591/src/zope/schema/tests

Modified Files:
	states.py tabcomplete.py test_accessors.py test_states.py 
	test_vocabulary.py 
Log Message:
new style implements()


=== Zope3/src/zope/schema/tests/states.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/tests/states.py:1.2	Tue May 20 12:10:30 2003
+++ Zope3/src/zope/schema/tests/states.py	Wed Jun  4 05:09:46 2003
@@ -16,7 +16,7 @@
 
 from zope.schema import interfaces
 from zope.schema import vocabulary
-
+from zope.interface import implements
 
 # This table is based on information from the United States Postal Service:
 # http://www.usps.com/ncsc/lookups/abbreviations.html#states
@@ -85,7 +85,7 @@
 
 class State:
     __slots__ = 'value', 'title'
-    __implements__ = interfaces.ITerm
+    implements(interfaces.ITerm)
 
     def __init__(self, value, title):
         self.value = value
@@ -101,7 +101,7 @@
 
 class StateVocabulary(object):
     __slots__ = ()
-    __implements__ = IStateVocabulary
+    implements(IStateVocabulary)
 
     def __init__(self, object=None):
         pass
@@ -120,7 +120,7 @@
 
 
 class StateSelectionField(vocabulary.VocabularyField):
-    __implements__ = vocabulary.VocabularyField.__implements__
+
     vocabulary = StateVocabulary()
 
     def __init__(self, **kw):


=== Zope3/src/zope/schema/tests/tabcomplete.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/tests/tabcomplete.py:1.2	Tue May 20 12:10:30 2003
+++ Zope3/src/zope/schema/tests/tabcomplete.py	Wed Jun  4 05:09:46 2003
@@ -16,10 +16,11 @@
 
 
 from zope.schema.interfaces import ITerm, ISubsetVocabulary, IVocabulary
+from zope.interface import implements
 
 
 class Term:
-    __implements__ = ITerm
+    implements(ITerm)
 
     def __init__(self, value):
         self.value = value
@@ -37,7 +38,7 @@
 
 
 class CompletionVocabulary(object):
-    __implements__ = IVocabulary
+    implements(IVocabulary)
 
     def __init__(self, values):
         # In practice, something more dynamic could be used to
@@ -71,7 +72,7 @@
 
 
 class SubsetCompletionVocabulary(CompletionVocabulary):
-    __implements__ = IVocabulary, ISubsetVocabulary
+    implements(ISubsetVocabulary)
 
     def __init__(self, values, master):
         super(SubsetCompletionVocabulary, self).__init__(values)


=== Zope3/src/zope/schema/tests/test_accessors.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/tests/test_accessors.py:1.2	Mon May 12 06:02:41 2003
+++ Zope3/src/zope/schema/tests/test_accessors.py	Wed Jun  4 05:09:46 2003
@@ -19,7 +19,7 @@
 """
 
 import unittest
-from zope.interface import Interface
+from zope.interface import Interface, implements
 from zope.schema import Text, accessors
 from zope.schema.interfaces import IText
 from zope.schema.accessors import FieldReadAccessor, FieldWriteAccessor
@@ -37,10 +37,10 @@
             getFoo, setFoo = accessors(field)
 
         class Bad:
-            __implements__ = I
+            implements(I)
 
         class Good:
-            __implements__ = I
+            implements(I)
 
             def getFoo(self):
                 return u"foo"


=== Zope3/src/zope/schema/tests/test_states.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/tests/test_states.py:1.2	Tue May 20 12:10:30 2003
+++ Zope3/src/zope/schema/tests/test_states.py	Wed Jun  4 05:09:46 2003
@@ -16,7 +16,7 @@
 
 import unittest
 
-from zope.interface import Interface
+from zope.interface import Interface, implements
 
 from zope.schema import vocabulary
 from zope.schema.tests import states
@@ -47,7 +47,7 @@
         )
 
 class BirthInfo:
-    __implements__ = IBirthInfo
+    implements(IBirthInfo)
 
     def __init__(self):
         self.state = state


=== Zope3/src/zope/schema/tests/test_vocabulary.py 1.6 => 1.7 ===
--- Zope3/src/zope/schema/tests/test_vocabulary.py:1.6	Tue Jun  3 18:46:28 2003
+++ Zope3/src/zope/schema/tests/test_vocabulary.py	Wed Jun  4 05:09:46 2003
@@ -17,7 +17,7 @@
 import unittest
 
 from zope.interface.verify import verifyObject
-from zope.interface import Interface
+from zope.interface import Interface, implements
 
 from zope.schema import interfaces
 from zope.schema import vocabulary
@@ -60,7 +60,7 @@
     pass
 
 class SampleVocabulary:
-    __implements__ = interfaces.IVocabulary
+    implements(interfaces.IVocabulary)
 
     def __contains__(self, value):
         return 0 <= value < 10
@@ -129,12 +129,12 @@
 
 
 class SimpleVocabularyTests(unittest.TestCase):
-    
+
     def setUp(self):
         self.list_vocab = vocabulary.SimpleVocabulary([1, 2, 3])
         self.items_vocab = vocabulary.SimpleVocabulary.fromItems(
             [('one', 1), ('two', 2), ('three', 3), ('fore!', 4)])
-    
+
     def test_simple_term(self):
         t = vocabulary.SimpleTerm(1)
         verifyObject(interfaces.ITokenizedTerm, t)
@@ -144,18 +144,18 @@
         verifyObject(interfaces.ITokenizedTerm, t)
         self.assertEqual(t.value, 1)
         self.assertEqual(t.token, "One")
-        
+
     def test_order(self):
         value = 1
         for t in self.list_vocab:
             self.assertEqual(t.value, value)
             value += 1
-            
+
         value = 1
         for t in self.items_vocab:
             self.assertEqual(t.value, value)
             value += 1
-    
+
     def test_implementation(self):
         self.failUnless(verifyObject(interfaces.IVocabulary, self.list_vocab))
         self.failUnless(
@@ -163,38 +163,38 @@
         self.failUnless(verifyObject(interfaces.IVocabulary, self.items_vocab))
         self.failUnless(
             verifyObject(interfaces.IVocabularyTokenized, self.items_vocab))
-            
+
     def test_addt_interfaces(self):
         class IStupid(Interface):
             pass
         v = vocabulary.SimpleVocabulary([1, 2, 3], IStupid)
         self.failUnless(IStupid.isImplementedBy(v))
-    
+
     def test_len(self):
         self.assertEqual(len(self.list_vocab), 3)
         self.assertEqual(len(self.items_vocab), 4)
-    
+
     def test_contains(self):
         for v in (self.list_vocab, self.items_vocab):
             self.assert_(1 in v and 2 in v and 3 in v)
             self.assert_(5 not in v)
-            
+
     def test_get_query(self):
         self.assert_(self.list_vocab.getQuery() is None)
-        
+
     def test_iter_and_get_term(self):
         for v in (self.list_vocab, self.items_vocab):
             for term in v:
                 self.assert_(v.getTerm(term.value) is term)
                 self.assert_(v.getTermByToken(term.token) is term)
-        
+
     def test_nonunique_tokens(self):
         self.assertRaises(
             AssertionError, vocabulary.SimpleVocabulary, [2, '2'])
         self.assertRaises(
             AssertionError, vocabulary.SimpleVocabulary.fromItems, 
             [(1, 'one'), ('1', 'another one')])
-        
+
 
 def test_suite():
     suite = unittest.makeSuite(RegistryTests)