[TIP] Capture HTTP traffic

Alfredo Deza alfredodeza at gmail.com
Fri Nov 5 05:38:25 PDT 2010


On Fri, Nov 5, 2010 at 4:52 AM, Alex <alex.lavoro.propio at gmail.com> wrote:

> Being the test target is a C++ application (or whichever foreign
> language the access to source code is not available), we first exclude
> Pythonic http libraries.
>
> I prefer not to hijack host configuration, use a proxy, or mock the
> server, since they either result in a lot of work, and difficult to be
> deployed in a CI server like Hudson, in which the test are not only
> run automatically, but the "setup" (hijack host file) and "restore" of
> the test environment is also preferably done automatically.
>
> We use Turbogears (based on Pylons) at work and we faced similar issues as
the ones you
are describing.



> The best solution would be a high-level (HTTP-level) Python
> module/wrapper for 'pycap', which operates in 'packet' level. This
> said module use pycap to capture and filter HTTP requests and returns
> the result in a more Pythonic data structures. This module should
> start a thread which captures HTTP requests while the test case is
> being executed.
>
> I cannot find anything which does what I've just describe. Please
> correct if I am wrong.
>
>
I think no one has mentioned it in this thread, but to test our application
we use
TestApp [1] from WebTest [2] (by Ian Bicking) which covers most of what you
mention.

All requests are captured, and you can evaluate any parts of the response.

We hook WebTest into the setUp method and we get full isolation from
other tests that are running, we even got py.test to run in parallel with
this same method achieving total isolation from other tests.

[1]  http://blog.ianbicking.org/2010/04/02/webtest-http-testing/
[2]  http://pythonpaste.org/webtest/class-webtest.TestApp.html


> Alex.
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20101105/5d8ceca6/attachment.html>


More information about the testing-in-python mailing list