This file is indexed.

/usr/share/doc/python-werkzeug-doc/html/test.html is in python-werkzeug-doc 0.10.4+dfsg1-1ubuntu1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Test Utilities &mdash; Werkzeug 0.10.4 documentation</title>
    
    <link rel="stylesheet" href="_static/werkzeug.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '0.10.4',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="Werkzeug 0.10.4 documentation" href="index.html" />
    <link rel="next" title="Debugging Applications" href="debug.html" />
    <link rel="prev" title="Serving WSGI Applications" href="serving.html" /> 
  </head>
  <body role="document">
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="debug.html" title="Debugging Applications"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="serving.html" title="Serving WSGI Applications"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Werkzeug 0.10.4 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-werkzeug.test">
<span id="test-utilities"></span><h1>Test Utilities<a class="headerlink" href="#module-werkzeug.test" title="Permalink to this headline"></a></h1>
<p>Quite often you want to unittest your application or just check the output
from an interactive python session.  In theory that is pretty simple because
you can fake a WSGI environment and call the application with a dummy
<cite>start_response</cite> and iterate over the application iterator but there are
argumentably better ways to interact with an application.</p>
<div class="section" id="diving-in">
<h2>Diving In<a class="headerlink" href="#diving-in" title="Permalink to this headline"></a></h2>
<p>Werkzeug provides a <cite>Client</cite> object which you can pass a WSGI application (and
optionally a response wrapper) which you can use to send virtual requests to
the application.</p>
<p>A response wrapper is a callable that takes three arguments: the application
iterator, the status and finally a list of headers.  The default response
wrapper returns a tuple.  Because response objects have the same signature,
you can use them as response wrapper, ideally by subclassing them and hooking
in test functionality.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.test</span> <span class="kn">import</span> <span class="n">Client</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.testapp</span> <span class="kn">import</span> <span class="n">test_app</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="kn">import</span> <span class="n">BaseResponse</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">test_app</span><span class="p">,</span> <span class="n">BaseResponse</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">resp</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">resp</span><span class="o">.</span><span class="n">status_code</span>
<span class="go">200</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">resp</span><span class="o">.</span><span class="n">headers</span>
<span class="go">Headers([(&#39;Content-Type&#39;, &#39;text/html; charset=utf-8&#39;), (&#39;Content-Length&#39;, &#39;8339&#39;)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">resp</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
<span class="go">&#39;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&#39;</span>
</pre></div>
</div>
<p>Or without a wrapper defined:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">test_app</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">app_iter</span><span class="p">,</span> <span class="n">status</span><span class="p">,</span> <span class="n">headers</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">status</span>
<span class="go">&#39;200 OK&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">headers</span>
<span class="go">[(&#39;Content-Type&#39;, &#39;text/html; charset=utf-8&#39;), (&#39;Content-Length&#39;, &#39;8339&#39;)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">app_iter</span><span class="p">)</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
<span class="go">&#39;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&#39;</span>
</pre></div>
</div>
</div>
<div class="section" id="environment-building">
<h2>Environment Building<a class="headerlink" href="#environment-building" title="Permalink to this headline"></a></h2>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
<p>The easiest way to interactively test applications is using the
<a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal"><span class="pre">EnvironBuilder</span></code></a>.  It can create both standard WSGI environments
and request objects.</p>
<p>The following example creates a WSGI environment with one uploaded file
and a form field:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.test</span> <span class="kn">import</span> <span class="n">EnvironBuilder</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">StringIO</span> <span class="kn">import</span> <span class="n">StringIO</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span> <span class="o">=</span> <span class="n">EnvironBuilder</span><span class="p">(</span><span class="n">method</span><span class="o">=</span><span class="s1">&#39;POST&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;foo&#39;</span><span class="p">:</span> <span class="s1">&#39;this is some text&#39;</span><span class="p">,</span>
<span class="gp">... </span>     <span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="s1">&#39;my file contents&#39;</span><span class="p">),</span> <span class="s1">&#39;test.txt&#39;</span><span class="p">)})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">env</span> <span class="o">=</span> <span class="n">builder</span><span class="o">.</span><span class="n">get_environ</span><span class="p">()</span>
</pre></div>
</div>
<p>The resulting environment is a regular WSGI environment that can be used for
further processing:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="kn">import</span> <span class="n">Request</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span> <span class="o">=</span> <span class="n">Request</span><span class="p">(</span><span class="n">env</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span><span class="o">.</span><span class="n">form</span><span class="p">[</span><span class="s1">&#39;foo&#39;</span><span class="p">]</span>
<span class="go">u&#39;this is some text&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span><span class="o">.</span><span class="n">files</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span>
<span class="go">&lt;FileStorage: u&#39;test.txt&#39; (&#39;text/plain&#39;)&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span><span class="o">.</span><span class="n">files</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="go">&#39;my file contents&#39;</span>
</pre></div>
</div>
<p>The <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal"><span class="pre">EnvironBuilder</span></code></a> figures out the content type automatically if you
pass a dict to the constructor as <cite>data</cite>.  If you provide a string or an
input stream you have to do that yourself.</p>
<p>By default it will try to use <code class="docutils literal"><span class="pre">application/x-www-form-urlencoded</span></code> and only
use <code class="docutils literal"><span class="pre">multipart/form-data</span></code> if files are uploaded:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span> <span class="o">=</span> <span class="n">EnvironBuilder</span><span class="p">(</span><span class="n">method</span><span class="o">=</span><span class="s1">&#39;POST&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;foo&#39;</span><span class="p">:</span> <span class="s1">&#39;bar&#39;</span><span class="p">})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span><span class="o">.</span><span class="n">content_type</span>
<span class="go">&#39;application/x-www-form-urlencoded&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span><span class="o">.</span><span class="n">files</span><span class="p">[</span><span class="s1">&#39;foo&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">(</span><span class="s1">&#39;contents&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span><span class="o">.</span><span class="n">content_type</span>
<span class="go">&#39;multipart/form-data&#39;</span>
</pre></div>
</div>
<p>If a string is provided as data (or an input stream) you have to specify
the content type yourself:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span> <span class="o">=</span> <span class="n">EnvironBuilder</span><span class="p">(</span><span class="n">method</span><span class="o">=</span><span class="s1">&#39;POST&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="s1">&#39;{&quot;json&quot;: &quot;this is&quot;}&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span><span class="o">.</span><span class="n">content_type</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span><span class="o">.</span><span class="n">content_type</span> <span class="o">=</span> <span class="s1">&#39;application/json&#39;</span>
</pre></div>
</div>
</div>
<div class="section" id="testing-api">
<h2>Testing API<a class="headerlink" href="#testing-api" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="werkzeug.test.EnvironBuilder">
<em class="property">class </em><code class="descclassname">werkzeug.test.</code><code class="descname">EnvironBuilder</code><span class="sig-paren">(</span><em>path='/'</em>, <em>base_url=None</em>, <em>query_string=None</em>, <em>method='GET'</em>, <em>input_stream=None</em>, <em>content_type=None</em>, <em>content_length=None</em>, <em>errors_stream=None</em>, <em>multithread=False</em>, <em>multiprocess=False</em>, <em>run_once=False</em>, <em>headers=None</em>, <em>data=None</em>, <em>environ_base=None</em>, <em>environ_overrides=None</em>, <em>charset='utf-8'</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.EnvironBuilder" title="Permalink to this definition"></a></dt>
<dd><p>This class can be used to conveniently create a WSGI environment
for testing purposes.  It can be used to quickly create WSGI environments
or request objects from arbitrary data.</p>
<p>The signature of this class is also used in some other places as of
Werkzeug 0.5 (<a class="reference internal" href="#werkzeug.test.create_environ" title="werkzeug.test.create_environ"><code class="xref py py-func docutils literal"><span class="pre">create_environ()</span></code></a>, <code class="xref py py-meth docutils literal"><span class="pre">BaseResponse.from_values()</span></code>,
<a class="reference internal" href="#werkzeug.test.Client.open" title="werkzeug.test.Client.open"><code class="xref py py-meth docutils literal"><span class="pre">Client.open()</span></code></a>).  Because of this most of the functionality is
available through the constructor alone.</p>
<p>Files and regular form data can be manipulated independently of each
other with the <code class="xref py py-attr docutils literal"><span class="pre">form</span></code> and <code class="xref py py-attr docutils literal"><span class="pre">files</span></code> attributes, but are
passed with the same argument to the constructor: <cite>data</cite>.</p>
<p><cite>data</cite> can be any of these values:</p>
<ul class="simple">
<li>a <cite>str</cite>: If it&#8217;s a string it is converted into a <a class="reference internal" href="#werkzeug.test.EnvironBuilder.input_stream" title="werkzeug.test.EnvironBuilder.input_stream"><code class="xref py py-attr docutils literal"><span class="pre">input_stream</span></code></a>,
the <a class="reference internal" href="#werkzeug.test.EnvironBuilder.content_length" title="werkzeug.test.EnvironBuilder.content_length"><code class="xref py py-attr docutils literal"><span class="pre">content_length</span></code></a> is set and you have to provide a
<a class="reference internal" href="#werkzeug.test.EnvironBuilder.content_type" title="werkzeug.test.EnvironBuilder.content_type"><code class="xref py py-attr docutils literal"><span class="pre">content_type</span></code></a>.</li>
<li>a <cite>dict</cite>: If it&#8217;s a dict the keys have to be strings and the values
any of the following objects:<ul>
<li>a <code class="xref py py-class docutils literal"><span class="pre">file</span></code>-like object.  These are converted into
<code class="xref py py-class docutils literal"><span class="pre">FileStorage</span></code> objects automatically.</li>
<li>a tuple.  The <code class="xref py py-meth docutils literal"><span class="pre">add_file()</span></code> method is called
with the tuple items as positional arguments.</li>
</ul>
</li>
</ul>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6: </span><cite>path</cite> and <cite>base_url</cite> can now be unicode strings that are encoded using
the <code class="xref py py-func docutils literal"><span class="pre">iri_to_uri()</span></code> function.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>path</strong> &#8211; the path of the request.  In the WSGI environment this will
end up as <cite>PATH_INFO</cite>.  If the <cite>query_string</cite> is not defined
and there is a question mark in the <cite>path</cite> everything after
it is used as query string.</li>
<li><strong>base_url</strong> &#8211; the base URL is a URL that is used to extract the WSGI
URL scheme, host (server name + server port) and the
script root (<cite>SCRIPT_NAME</cite>).</li>
<li><strong>query_string</strong> &#8211; an optional string or dict with URL parameters.</li>
<li><strong>method</strong> &#8211; the HTTP method to use, defaults to <cite>GET</cite>.</li>
<li><strong>input_stream</strong> &#8211; an optional input stream.  Do not specify this and
<cite>data</cite>.  As soon as an input stream is set you can&#8217;t
modify <a class="reference internal" href="#werkzeug.test.EnvironBuilder.args" title="werkzeug.test.EnvironBuilder.args"><code class="xref py py-attr docutils literal"><span class="pre">args</span></code></a> and <code class="xref py py-attr docutils literal"><span class="pre">files</span></code> unless you
set the <a class="reference internal" href="#werkzeug.test.EnvironBuilder.input_stream" title="werkzeug.test.EnvironBuilder.input_stream"><code class="xref py py-attr docutils literal"><span class="pre">input_stream</span></code></a> to <cite>None</cite> again.</li>
<li><strong>content_type</strong> &#8211; The content type for the request.  As of 0.5 you
don&#8217;t have to provide this when specifying files
and form data via <cite>data</cite>.</li>
<li><strong>content_length</strong> &#8211; The content length for the request.  You don&#8217;t
have to specify this when providing data via
<cite>data</cite>.</li>
<li><strong>errors_stream</strong> &#8211; an optional error stream that is used for
<cite>wsgi.errors</cite>.  Defaults to <code class="xref py py-data docutils literal"><span class="pre">stderr</span></code>.</li>
<li><strong>multithread</strong> &#8211; controls <cite>wsgi.multithread</cite>.  Defaults to <cite>False</cite>.</li>
<li><strong>multiprocess</strong> &#8211; controls <cite>wsgi.multiprocess</cite>.  Defaults to <cite>False</cite>.</li>
<li><strong>run_once</strong> &#8211; controls <cite>wsgi.run_once</cite>.  Defaults to <cite>False</cite>.</li>
<li><strong>headers</strong> &#8211; an optional list or <code class="xref py py-class docutils literal"><span class="pre">Headers</span></code> object of headers.</li>
<li><strong>data</strong> &#8211; a string or dict of form data.  See explanation above.</li>
<li><strong>environ_base</strong> &#8211; an optional dict of environment defaults.</li>
<li><strong>environ_overrides</strong> &#8211; an optional dict of environment overrides.</li>
<li><strong>charset</strong> &#8211; the charset used to encode unicode data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.path">
<code class="descname">path</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.path" title="Permalink to this definition"></a></dt>
<dd><p>The path of the application.  (aka <cite>PATH_INFO</cite>)</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.charset">
<code class="descname">charset</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.charset" title="Permalink to this definition"></a></dt>
<dd><p>The charset used to encode unicode data.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.headers">
<code class="descname">headers</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.headers" title="Permalink to this definition"></a></dt>
<dd><p>A <code class="xref py py-class docutils literal"><span class="pre">Headers</span></code> object with the request headers.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.errors_stream">
<code class="descname">errors_stream</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.errors_stream" title="Permalink to this definition"></a></dt>
<dd><p>The error stream used for the <cite>wsgi.errors</cite> stream.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.multithread">
<code class="descname">multithread</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.multithread" title="Permalink to this definition"></a></dt>
<dd><p>The value of <cite>wsgi.multithread</cite></p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.multiprocess">
<code class="descname">multiprocess</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.multiprocess" title="Permalink to this definition"></a></dt>
<dd><p>The value of <cite>wsgi.multiprocess</cite></p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.environ_base">
<code class="descname">environ_base</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.environ_base" title="Permalink to this definition"></a></dt>
<dd><p>The dict used as base for the newly create environ.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.environ_overrides">
<code class="descname">environ_overrides</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.environ_overrides" title="Permalink to this definition"></a></dt>
<dd><p>A dict with values that are used to override the generated environ.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.input_stream">
<code class="descname">input_stream</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.input_stream" title="Permalink to this definition"></a></dt>
<dd><p>The optional input stream.  This and <code class="xref py py-attr docutils literal"><span class="pre">form</span></code> / <code class="xref py py-attr docutils literal"><span class="pre">files</span></code>
is mutually exclusive.  Also do not provide this stream if the
request method is not <cite>POST</cite> / <cite>PUT</cite> or something comparable.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.args">
<code class="descname">args</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.args" title="Permalink to this definition"></a></dt>
<dd><p>The URL arguments as <code class="xref py py-class docutils literal"><span class="pre">MultiDict</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.base_url">
<code class="descname">base_url</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.base_url" title="Permalink to this definition"></a></dt>
<dd><p>The base URL is a URL that is used to extract the WSGI
URL scheme, host (server name + server port) and the
script root (<cite>SCRIPT_NAME</cite>).</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.EnvironBuilder.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.EnvironBuilder.close" title="Permalink to this definition"></a></dt>
<dd><p>Closes all files.  If you put real <code class="xref py py-class docutils literal"><span class="pre">file</span></code> objects into the
<code class="xref py py-attr docutils literal"><span class="pre">files</span></code> dict you can call this method to automatically close
them all in one go.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.content_length">
<code class="descname">content_length</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.content_length" title="Permalink to this definition"></a></dt>
<dd><p>The content length as integer.  Reflected from and to the
<a class="reference internal" href="#werkzeug.test.EnvironBuilder.headers" title="werkzeug.test.EnvironBuilder.headers"><code class="xref py py-attr docutils literal"><span class="pre">headers</span></code></a>.  Do not set if you set <code class="xref py py-attr docutils literal"><span class="pre">files</span></code> or
<code class="xref py py-attr docutils literal"><span class="pre">form</span></code> for auto detection.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.content_type">
<code class="descname">content_type</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.content_type" title="Permalink to this definition"></a></dt>
<dd><p>The content type for the request.  Reflected from and to the
<a class="reference internal" href="#werkzeug.test.EnvironBuilder.headers" title="werkzeug.test.EnvironBuilder.headers"><code class="xref py py-attr docutils literal"><span class="pre">headers</span></code></a>.  Do not set if you set <code class="xref py py-attr docutils literal"><span class="pre">files</span></code> or
<code class="xref py py-attr docutils literal"><span class="pre">form</span></code> for auto detection.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.EnvironBuilder.get_environ">
<code class="descname">get_environ</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.EnvironBuilder.get_environ" title="Permalink to this definition"></a></dt>
<dd><p>Return the built environ.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.EnvironBuilder.get_request">
<code class="descname">get_request</code><span class="sig-paren">(</span><em>cls=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.EnvironBuilder.get_request" title="Permalink to this definition"></a></dt>
<dd><p>Returns a request with the data.  If the request class is not
specified <a class="reference internal" href="#werkzeug.test.EnvironBuilder.request_class" title="werkzeug.test.EnvironBuilder.request_class"><code class="xref py py-attr docutils literal"><span class="pre">request_class</span></code></a> is used.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>cls</strong> &#8211; The request wrapper to use.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt>
<code class="descname">input_stream</code></dt>
<dd><p>An optional input stream.  If you set this it will clear
<code class="xref py py-attr docutils literal"><span class="pre">form</span></code> and <code class="xref py py-attr docutils literal"><span class="pre">files</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.query_string">
<code class="descname">query_string</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.query_string" title="Permalink to this definition"></a></dt>
<dd><p>The query string.  If you set this to a string <a class="reference internal" href="#werkzeug.test.EnvironBuilder.args" title="werkzeug.test.EnvironBuilder.args"><code class="xref py py-attr docutils literal"><span class="pre">args</span></code></a> will
no longer be available.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.request_class">
<code class="descname">request_class</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.request_class" title="Permalink to this definition"></a></dt>
<dd><p>the default request class for <a class="reference internal" href="#werkzeug.test.EnvironBuilder.get_request" title="werkzeug.test.EnvironBuilder.get_request"><code class="xref py py-meth docutils literal"><span class="pre">get_request()</span></code></a></p>
<p>alias of <code class="xref py py-class docutils literal"><span class="pre">BaseRequest</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.server_name">
<code class="descname">server_name</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.server_name" title="Permalink to this definition"></a></dt>
<dd><p>The server name (read-only, use <code class="xref py py-attr docutils literal"><span class="pre">host</span></code> to set)</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.server_port">
<code class="descname">server_port</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.server_port" title="Permalink to this definition"></a></dt>
<dd><p>The server port as integer (read-only, use <code class="xref py py-attr docutils literal"><span class="pre">host</span></code> to set)</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.server_protocol">
<code class="descname">server_protocol</code><em class="property"> = 'HTTP/1.1'</em><a class="headerlink" href="#werkzeug.test.EnvironBuilder.server_protocol" title="Permalink to this definition"></a></dt>
<dd><p>the server protocol to use.  defaults to HTTP/1.1</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.wsgi_version">
<code class="descname">wsgi_version</code><em class="property"> = (1, 0)</em><a class="headerlink" href="#werkzeug.test.EnvironBuilder.wsgi_version" title="Permalink to this definition"></a></dt>
<dd><p>the wsgi version to use.  defaults to (1, 0)</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.test.Client">
<em class="property">class </em><code class="descclassname">werkzeug.test.</code><code class="descname">Client</code><span class="sig-paren">(</span><em>application</em>, <em>response_wrapper=None</em>, <em>use_cookies=True</em>, <em>allow_subdomain_redirects=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client" title="Permalink to this definition"></a></dt>
<dd><p>This class allows to send requests to a wrapped application.</p>
<p>The response wrapper can be a class or factory function that takes
three arguments: app_iter, status and headers.  The default response
wrapper just returns a tuple.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">ClientResponse</span><span class="p">(</span><span class="n">BaseResponse</span><span class="p">):</span>
    <span class="o">...</span>

<span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">MyApplication</span><span class="p">(),</span> <span class="n">response_wrapper</span><span class="o">=</span><span class="n">ClientResponse</span><span class="p">)</span>
</pre></div>
</div>
<p>The use_cookies parameter indicates whether cookies should be stored and
sent for subsequent requests. This is True by default, but passing False
will disable this behaviour.</p>
<p>If you want to request some subdomain of your application you may set
<cite>allow_subdomain_redirects</cite> to <cite>True</cite> as if not no external redirects
are allowed.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.5: </span><cite>use_cookies</cite> is new in this version.  Older versions did not provide
builtin cookie support.</p>
</div>
<dl class="method">
<dt id="werkzeug.test.Client.open">
<code class="descname">open</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.open" title="Permalink to this definition"></a></dt>
<dd><p>Takes the same arguments as the <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal"><span class="pre">EnvironBuilder</span></code></a> class with
some additions:  You can provide a <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal"><span class="pre">EnvironBuilder</span></code></a> or a WSGI
environment as only argument instead of the <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal"><span class="pre">EnvironBuilder</span></code></a>
arguments and two optional keyword arguments (<cite>as_tuple</cite>, <cite>buffered</cite>)
that change the type of the return value or the way the application is
executed.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>If a dict is provided as file in the dict for the <cite>data</cite> parameter
the content type has to be called <cite>content_type</cite> now instead of
<cite>mimetype</cite>.  This change was made for consistency with
<code class="xref py py-class docutils literal"><span class="pre">werkzeug.FileWrapper</span></code>.</p>
<blockquote>
<div>The <cite>follow_redirects</cite> parameter was added to <a class="reference internal" href="#werkzeug.test.Client.open" title="werkzeug.test.Client.open"><code class="xref py py-func docutils literal"><span class="pre">open()</span></code></a>.</div></blockquote>
</div>
<p>Additional parameters:</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>as_tuple</strong> &#8211; Returns a tuple in the form <code class="docutils literal"><span class="pre">(environ,</span> <span class="pre">result)</span></code></li>
<li><strong>buffered</strong> &#8211; Set this to True to buffer the application run.
This will automatically close the application for
you as well.</li>
<li><strong>follow_redirects</strong> &#8211; Set this to True if the <cite>Client</cite> should
follow HTTP redirects.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<p>Shortcut methods are available for many HTTP methods:</p>
<dl class="method">
<dt id="werkzeug.test.Client.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.get" title="Permalink to this definition"></a></dt>
<dd><p>Like open but method is enforced to GET.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.patch">
<code class="descname">patch</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.patch" title="Permalink to this definition"></a></dt>
<dd><p>Like open but method is enforced to PATCH.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.post">
<code class="descname">post</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.post" title="Permalink to this definition"></a></dt>
<dd><p>Like open but method is enforced to POST.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.head">
<code class="descname">head</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.head" title="Permalink to this definition"></a></dt>
<dd><p>Like open but method is enforced to HEAD.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.put">
<code class="descname">put</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.put" title="Permalink to this definition"></a></dt>
<dd><p>Like open but method is enforced to PUT.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.delete">
<code class="descname">delete</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.delete" title="Permalink to this definition"></a></dt>
<dd><p>Like open but method is enforced to DELETE.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.options">
<code class="descname">options</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.options" title="Permalink to this definition"></a></dt>
<dd><p>Like open but method is enforced to OPTIONS.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.trace">
<code class="descname">trace</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.trace" title="Permalink to this definition"></a></dt>
<dd><p>Like open but method is enforced to TRACE.</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="werkzeug.test.create_environ">
<code class="descclassname">werkzeug.test.</code><code class="descname">create_environ</code><span class="sig-paren">(</span><span class="optional">[</span><em>options</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.create_environ" title="Permalink to this definition"></a></dt>
<dd><p>Create a new WSGI environ dict based on the values passed.  The first
parameter should be the path of the request which defaults to &#8216;/&#8217;.  The
second one can either be an absolute path (in that case the host is
localhost:80) or a full path to the request with scheme, netloc port and
the path to the script.</p>
<p>This accepts the same arguments as the <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal"><span class="pre">EnvironBuilder</span></code></a>
constructor.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>This function is now a thin wrapper over <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal"><span class="pre">EnvironBuilder</span></code></a> which
was added in 0.5.  The <cite>headers</cite>, <cite>environ_base</cite>, <cite>environ_overrides</cite>
and <cite>charset</cite> parameters were added.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="werkzeug.test.run_wsgi_app">
<code class="descclassname">werkzeug.test.</code><code class="descname">run_wsgi_app</code><span class="sig-paren">(</span><em>app</em>, <em>environ</em>, <em>buffered=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.run_wsgi_app" title="Permalink to this definition"></a></dt>
<dd><p>Return a tuple in the form (app_iter, status, headers) of the
application output.  This works best if you pass it an application that
returns an iterator all the time.</p>
<p>Sometimes applications may use the <cite>write()</cite> callable returned
by the <cite>start_response</cite> function.  This tries to resolve such edge
cases automatically.  But if you don&#8217;t get the expected output you
should set <cite>buffered</cite> to <cite>True</cite> which enforces buffering.</p>
<p>If passed an invalid WSGI application the behavior of this function is
undefined.  Never pass non-conforming WSGI applications to this function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>app</strong> &#8211; the application to execute.</li>
<li><strong>buffered</strong> &#8211; set to <cite>True</cite> to enforce buffering.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">tuple in the form <code class="docutils literal"><span class="pre">(app_iter,</span> <span class="pre">status,</span> <span class="pre">headers)</span></code></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper"><p class="logo"><a href="index.html">
  <img class="logo" src="_static/werkzeug.png" alt="Logo"/>
</a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Test Utilities</a><ul>
<li><a class="reference internal" href="#diving-in">Diving In</a></li>
<li><a class="reference internal" href="#environment-building">Environment Building</a></li>
<li><a class="reference internal" href="#testing-api">Testing API</a></li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="serving.html" title="previous chapter">Serving WSGI Applications</a></li>
      <li>Next: <a href="debug.html" title="next chapter">Debugging Applications</a></li>
  </ul></li>
</ul>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/test.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy; Copyright 2011, The Werkzeug Team.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>