diff options
Diffstat (limited to 'pathod/templates/examples_context.html')
-rw-r--r-- | pathod/templates/examples_context.html | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/pathod/templates/examples_context.html b/pathod/templates/examples_context.html deleted file mode 100644 index 20b02c39..00000000 --- a/pathod/templates/examples_context.html +++ /dev/null @@ -1,24 +0,0 @@ -<div class="highlight"><pre><span class="kn">import</span> <span class="nn">requests</span> -<span class="kn">from</span> <span class="nn">pathod</span> <span class="kn">import</span> <span class="n">test</span> - - -<span class="k">def</span> <span class="nf">test_simple</span><span class="p">():</span> - <span class="sd">"""</span> -<span class="sd"> Testing the requests module with</span> -<span class="sd"> a pathod context manager.</span> -<span class="sd"> """</span> - <span class="c"># Start pathod in a separate thread</span> - <span class="k">with</span> <span class="n">test</span><span class="o">.</span><span class="n">Daemon</span><span class="p">()</span> <span class="k">as</span> <span class="n">d</span><span class="p">:</span> - <span class="c"># Get a URL for a pathod spec</span> - <span class="n">url</span> <span class="o">=</span> <span class="n">d</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="c"># ... and request it</span> - <span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">url</span><span class="p">)</span> - - <span class="c"># Check the returned data</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="c"># Check pathod's internal log</span> - <span class="n">log</span> <span class="o">=</span> <span class="n">d</span><span class="o">.</span><span class="n">last_log</span><span class="p">()[</span><span class="s">"request"</span><span class="p">]</span> - <span class="k">assert</span> <span class="n">log</span><span class="p">[</span><span class="s">"method"</span><span class="p">]</span> <span class="o">==</span> <span class="s">"PUT"</span> -</pre></div> |