Changeset 9689 for main/waeup.kofa/trunk/src/waeup/kofa/utils/tests
- Timestamp:
- 20 Nov 2012, 00:09:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_helpers.py
r9372 r9689 28 28 from cStringIO import StringIO 29 29 from zope import schema 30 from zope.interface import Interface, Attribute, implements 30 from zope.interface import Interface, Attribute, implements, implementer 31 31 from zope.security.testing import Principal, Participation 32 32 from zope.security.management import newInteraction, endInteraction … … 52 52 self.assertEqual(result4, 30) 53 53 return 54 55 def test_attrs_to_fields_properties(self): 56 # we can omit single fields in order to retrieve properties 57 class IMyInterface(Interface): 58 attr1 = schema.Int( 59 title = u'Attribute 1', readonly = True, default = 110, 60 ) 61 62 @helpers.attrs_to_fields 63 @implementer(IMyInterface) 64 class MyClass1(object): 65 @property 66 def attr1(self): 67 return 42 68 69 @implementer(IMyInterface) 70 class MyClass2(object): 71 @property 72 def attr1(self): 73 return 42 74 MyClass2 = helpers.attrs_to_fields(MyClass2, omit=['attr1']) 75 76 obj1 = MyClass1() 77 obj2 = MyClass2() 78 79 self.assertEqual(obj1.attr1, 110) 80 self.assertEqual(obj2.attr1, 42) 81 return 82 54 83 55 84 class RemoveFileOrDirectoryTestCase(unittest.TestCase): … … 461 490 contents, '\r\n') 462 491 return 492 463 493 464 494
Note: See TracChangeset for help on using the changeset viewer.