diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-30 17:29:36 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-30 17:29:36 +1200 |
commit | e52a37ffa962f662cfcab8056c8af5b0ac9f416b (patch) | |
tree | a7d9f4edf1080422edd19f1360298e914628e675 /libpathod/templates/examples_test.html | |
parent | e26aac1d3c6e4ca9f09cffa9d61d5a632dc35f14 (diff) | |
download | mitmproxy-e52a37ffa962f662cfcab8056c8af5b0ac9f416b.tar.gz mitmproxy-e52a37ffa962f662cfcab8056c8af5b0ac9f416b.tar.bz2 mitmproxy-e52a37ffa962f662cfcab8056c8af5b0ac9f416b.zip |
Cleanup of libpathod.test, test example for front page.
Diffstat (limited to 'libpathod/templates/examples_test.html')
-rw-r--r-- | libpathod/templates/examples_test.html | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libpathod/templates/examples_test.html b/libpathod/templates/examples_test.html new file mode 100644 index 00000000..57d39534 --- /dev/null +++ b/libpathod/templates/examples_test.html @@ -0,0 +1,18 @@ +<div class="highlight"><pre><span class="kn">import</span> <span class="nn">requests</span> +<span class="kn">from</span> <span class="nn">libpathod</span> <span class="kn">import</span> <span class="n">test</span> + +<span class="k">class</span> <span class="nc">Test</span><span class="p">:</span> + <span class="k">def</span> <span class="nf">setUp</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">daemon</span> <span class="o">=</span> <span class="n">test</span><span class="o">.</span><span class="n">Daemon</span><span class="p">()</span> + + <span class="k">def</span> <span class="nf">tearDown</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">daemon</span><span class="o">.</span><span class="n">shutdown</span><span class="p">()</span> + + <span class="k">def</span> <span class="nf">test_simple</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">daemon</span><span class="o">.</span><span class="n">p</span><span class="p">(</span><span class="s">"200:b@100"</span><span class="p">)</span> + <span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> + <span class="k">assert</span> <span class="n">r</span><span class="o">.</span><span class="n">status_code</span> <span class="o">==</span> <span class="mi">200</span> + <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">content</span><span class="p">)</span> <span class="o">==</span> <span class="mi">100</span> + <span class="n">log</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">daemon</span><span class="o">.</span><span class="n">last_log</span><span class="p">()</span> + <span class="k">assert</span> <span class="n">log</span><span class="p">[</span><span class="s">"request"</span><span class="p">][</span><span class="s">"method"</span><span class="p">]</span> <span class="o">==</span> <span class="s">"GET"</span> +</pre></div> |