Tim Knapp wrote at 2009-3-23 18:21 +1300: >I would like to override the DateTime.DateTime class within my >functional tests. I have tried mocking (via mocker) and injecting the >subclassed DateTime class into sys.modules (results in a >TraversalError). The fartherest I've gotten is to set DateTime.DateTime >= MySubclassedDateTime in my tests.py, which does work for the code >'within' the package(s) I'm testing but all the Zope core code (i.e. the >instance created within PloneTestCase) is still referencing the global >DateTime module. Has anyone successfully done this?
"import DateTime; DateTime=<myDateTimeClass>" should be able to replace the "DateTime" class -- sometimes. Be aware, however, that this replacing takes effect only after your assignment. Modules that already have imported the "DateTime" class will not be affected. -- Dieter _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )