On Monday 25 February 2002 22:40, Edmund Lian wrote:
> Is there an easy way for an instantiated object to test if it was
> instantiated within a WebKit instance, or from a command line? I
> have some classes that need to fake a self.request() method if they
> are being run outside WebKit (for testing, etc.) AFAIK, the
> standard __name__ == __main__ test isn't going to if I'm manually
> instantiating a test instance from the Python command line.
You might want to look at the way Cheetah does this. One of our
design goals was to make the .respond method work with or without
WebKit. The details are too complicated to explain in an email, but
you wanted to read Cheetah's src anyway, right?? ;) The gist of it
is that you need to provide a dummy Transaction object.
Cheetah.DummyTransaction should do the trick for you.