mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 10:26:23 +00:00
51 lines
1.4 KiB
HTML
51 lines
1.4 KiB
HTML
{% extends "docframe.html" %} {% block body %}
|
|
<div class="page-header">
|
|
<h1>
|
|
libpathod.test
|
|
<small>Using libpathod in unit tests.</small>
|
|
</h1>
|
|
</div>
|
|
|
|
<p>The <b>libpathod.test</b> module is a light, flexible testing layer for HTTP clients.
|
|
It works by firing up a Pathod instance in a separate thread, letting you use Pathod's
|
|
full abilities to generate responses, and then query Pathod's internal logs to establish
|
|
what happened. All the mechanics of startup, shutdown, finding free ports and so forth
|
|
are taken care of for you.
|
|
</p>
|
|
|
|
<p>The canonical docs can be accessed using pydoc: </p>
|
|
|
|
<pre class="terminal">pydoc libpathod.test</pre>
|
|
|
|
<p>
|
|
The remainder of this page demonstrates some common interaction patterns using
|
|
<a
|
|
href="http://nose.readthedocs.org/en/latest/">nose</a>. These examples are also applicable with only minor modification to most
|
|
commonly used Python testing engines.
|
|
</p>
|
|
|
|
<section>
|
|
<div class="page-header">
|
|
<h1>Context Manager</h1>
|
|
</div>
|
|
|
|
{% include "examples_context.html" %}
|
|
</section>
|
|
|
|
<section>
|
|
<div class="page-header">
|
|
<h1>One instance per test</h1>
|
|
</div>
|
|
|
|
{% include "examples_setup.html" %}
|
|
</section>
|
|
|
|
<section>
|
|
<div class="page-header">
|
|
<h1>One instance per suite</h1>
|
|
</div>
|
|
|
|
{% include "examples_setupall.html" %}
|
|
</section>
|
|
{% endblock %}
|