[Erp5-report] r18080 - /erp5/trunk/products/ERP5Type/tests/testERP5Type.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Dec 6 18:22:29 CET 2007
Author: jerome
Date: Thu Dec 6 18:22:29 2007
New Revision: 18080
URL: http://svn.erp5.org?rev=18080&view=rev
Log:
some tests for _aq_dynamic behaviour. This is probably not in the best place
for them ...
Modified:
erp5/trunk/products/ERP5Type/tests/testERP5Type.py
Modified: erp5/trunk/products/ERP5Type/tests/testERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testERP5Type.py?rev=18080&r1=18079&r2=18080&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testERP5Type.py (original)
+++ erp5/trunk/products/ERP5Type/tests/testERP5Type.py Thu Dec 6 18:22:29 2007
@@ -1807,6 +1807,37 @@
# ... other cases should be added here
+
+
+ # Tests for _aq_dynamic patch. Probably not in the right place.
+ def test_aq_dynamic(self):
+ doc = self.portal.person_module.newContent(portal_type='Person')
+ from Acquisition import Explicit
+
+ class Ok(Explicit):
+ aq_dynamic_calls = []
+ def _aq_dynamic(self, name):
+ self.aq_dynamic_calls.append(name)
+ return 'returned_attr'
+
+ ok = Ok().__of__(doc)
+ self.assertEquals('returned_attr', getattr(ok, 'attr'))
+ self.assertEquals(ok.aq_dynamic_calls, ['attr'])
+
+ def test_aq_dynamic_exception(self):
+ # if an exception is raised in _aq_dynamic, it should not be hidden
+ doc = self.portal.person_module.newContent(portal_type='Person')
+ from Acquisition import Explicit
+
+ class NotOk(Explicit):
+ def _aq_dynamic(self, name):
+ raise ValueError()
+
+ not_ok = NotOk().__of__(doc)
+ self.assertRaises(ValueError, getattr, not_ok, 'attr')
+ self.assertFalse(hasattr(not_ok, 'attr'))
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Type))
More information about the Erp5-report
mailing list