On Mon, 2009-03-23 at 12:45 +0000, Chris Withers wrote:
> Tim Knapp wrote:
> > 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?
> You should take a look at testfixtures ;-)
> Specifically, the @replace decorator for one test or the Replacer (to
> use in setUp and tearDown)
> NB: Make sure you replace it in the module where's *used*, not the
> module where it comes from...
Thanks. One thing, though, it appears that testfixtures requires python
2.5 as it tries to import functools that was introduced in python 2.5.
/me carries on trying to get it going :)
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists -