[Zope-Checkins] CVS: Zope3/lib/python/Interface/tests - testInterface.py:1.1.4.3.2.1

Jim Fulton jim@zope.com
Mon, 25 Mar 2002 14:38:42 -0500


Update of /cvs-repository/Zope3/lib/python/Interface/tests
In directory cvs.zope.org:/tmp/cvs-serv32313/tests

Modified Files:
      Tag: Zope3-publisher-refactor-branch
	testInterface.py 
Log Message:
Fixed Attribute so that you no longer need to give a dang attribute
name as long as the doc has a space in it. :)

For example:

  class IFoo(Interface):

     spam = Attribute("The spam thingy")





=== Zope3/lib/python/Interface/tests/testInterface.py 1.1.4.3 => 1.1.4.3.2.1 ===
 from Interface.Implements import objectImplements
 from Interface import Interface
+from Interface.Attribute import Attribute
 
 class InterfaceTests(unittest.TestCase):
 
@@ -84,13 +85,13 @@
         names = list(_I2.names()); names.sort()
         self.assertEqual(names, ['f21', 'f22', 'f23'])
         names = list(_I2.names(1)); names.sort()
-        self.assertEqual(names, ['f11', 'f12', 'f21', 'f22', 'f23'])
+        self.assertEqual(names, ['a1', 'f11', 'f12', 'f21', 'f22', 'f23'])
 
     def test_namesAndDescriptions(self):
         names = [nd[0] for nd in _I2.namesAndDescriptions()]; names.sort()
         self.assertEqual(names, ['f21', 'f22', 'f23'])
         names = [nd[0] for nd in _I2.namesAndDescriptions(1)]; names.sort()
-        self.assertEqual(names, ['f11', 'f12', 'f21', 'f22', 'f23'])
+        self.assertEqual(names, ['a1', 'f11', 'f12', 'f21', 'f22', 'f23'])
 
         for name, d in _I2.namesAndDescriptions(1):
             self.assertEqual(name, d.__name__)
@@ -100,9 +101,17 @@
         self.assertEqual(_I2.getDescriptionFor('f22').__name__, 'f22')
         self.assertEqual(_I2.getDescriptionFor('f33', self), self)
         self.assertRaises(KeyError, _I2.getDescriptionFor, 'f33')
+
+    def testAttr(self):
+        description = _I2.getDescriptionFor('a1')
+        self.assertEqual(description.__name__, 'a1')
+        self.assertEqual(description.__doc__, 'This is an attribute')
     
 
 class _I1(Interface):
+
+    a1 = Attribute("This is an attribute")
+    
     def f11(): pass
     def f12(): pass