On Dec 3, 2005, at 11:08 AM, Jens Vagelpohl wrote:

On 3 Dec 2005, at 15:57, Paul Winkler wrote:
One thought that occurs to me is to replace httplib.HTTPConnection with a mock object of some sort that allows easy verification of its input. So we assume that httplib works, as a proper unit test should I think. How to do this? One idea is to monkeypatch httplib during the course of the test case, and replace and then when the test finishes, restore the
old httplib.HTTPConnection.  But this idea smells pretty bad to me.
Another thought: Maybe before doing anything else, I should make the
client class used by AcceleratedHTTPCache configurable, so I can more
easily get a mock in there.  Something like:

I like the secondary route, but I'm not sure the production code should contain "testing only" turds. :)

FWIW, I put "testing only" turds all the time in production code. It's pretty sane as long as you put a comment in the code that says "this dance performed to service unit tests" or somesuch. And it makes life much easier than needing to dummy up *everything*.

- C

Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Reply via email to