/usr/share/doc/python-pytest/html/parametrize.html is in python-pytest-doc 3.3.2-2.
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 | <!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>Parametrizing fixtures and test functions — pytest documentation</title>
<link rel="stylesheet" href="_static/flasky.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '3.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</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="shortcut icon" href="_static/pytest1favi.ico"/>
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Cache: working with cross-testrun state" href="cache.html" />
<link rel="prev" title="Skip and xfail: dealing with tests that cannot succeed" href="skipping.html" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
</head>
<body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="cache.html" title="Cache: working with cross-testrun state"
accesskey="N">next</a></li>
<li class="right" >
<a href="skipping.html" title="Skip and xfail: dealing with tests that cannot succeed"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="contents.html">pytest-3.3</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="parametrizing-fixtures-and-test-functions">
<span id="parametrize-basics"></span><span id="parametrize"></span><span id="parametrized-test-functions"></span><span id="parametrizing-tests"></span><span id="test-generators"></span><h1>Parametrizing fixtures and test functions<a class="headerlink" href="#parametrizing-fixtures-and-test-functions" title="Permalink to this headline">¶</a></h1>
<p>pytest enables test parametrization at several levels:</p>
<ul class="simple">
<li><code class="xref py py-func docutils literal"><span class="pre">pytest.fixture()</span></code> allows one to <a class="reference internal" href="fixture.html#fixture-parametrize"><span class="std std-ref">parametrize fixture
functions</span></a>.</li>
</ul>
<ul class="simple">
<li><a class="reference internal" href="#pytest-mark-parametrize">@pytest.mark.parametrize</a> allows one to define multiple sets of
arguments and fixtures at the test function or class.</li>
<li><a class="reference internal" href="#pytest-generate-tests">pytest_generate_tests</a> allows one to define custom parametrization
schemes or extensions.</li>
</ul>
<div class="section" id="pytest-mark-parametrize-parametrizing-test-functions">
<span id="pytest-mark-parametrize"></span><span id="parametrizemark"></span><h2><code class="docutils literal"><span class="pre">@pytest.mark.parametrize</span></code>: parametrizing test functions<a class="headerlink" href="#pytest-mark-parametrize-parametrizing-test-functions" title="Permalink to this headline">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified">New in version 2.2.</span></p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 2.4: </span>Several improvements.</p>
</div>
<p>The builtin <code class="docutils literal"><span class="pre">pytest.mark.parametrize</span></code> decorator enables
parametrization of arguments for a test function. Here is a typical example
of a test function that implements checking that a certain input leads
to an expected output:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># content of test_expectation.py</span>
<span class="kn">import</span> <span class="nn">pytest</span>
<span class="nd">@pytest</span><span class="o">.</span><span class="n">mark</span><span class="o">.</span><span class="n">parametrize</span><span class="p">(</span><span class="s2">"test_input,expected"</span><span class="p">,</span> <span class="p">[</span>
<span class="p">(</span><span class="s2">"3+5"</span><span class="p">,</span> <span class="mi">8</span><span class="p">),</span>
<span class="p">(</span><span class="s2">"2+4"</span><span class="p">,</span> <span class="mi">6</span><span class="p">),</span>
<span class="p">(</span><span class="s2">"6*9"</span><span class="p">,</span> <span class="mi">42</span><span class="p">),</span>
<span class="p">])</span>
<span class="k">def</span> <span class="nf">test_eval</span><span class="p">(</span><span class="n">test_input</span><span class="p">,</span> <span class="n">expected</span><span class="p">):</span>
<span class="k">assert</span> <span class="nb">eval</span><span class="p">(</span><span class="n">test_input</span><span class="p">)</span> <span class="o">==</span> <span class="n">expected</span>
</pre></div>
</div>
<p>Here, the <code class="docutils literal"><span class="pre">@parametrize</span></code> decorator defines three different <code class="docutils literal"><span class="pre">(test_input,expected)</span></code>
tuples so that the <code class="docutils literal"><span class="pre">test_eval</span></code> function will run three times using
them in turn:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR, inifile:
collected 3 items
test_expectation.py ..F [100%]
================================= FAILURES =================================
____________________________ test_eval[6*9-42] _____________________________
test_input = '6*9', expected = 42
@pytest.mark.parametrize("test_input,expected", [
("3+5", 8),
("2+4", 6),
("6*9", 42),
])
def test_eval(test_input, expected):
> assert eval(test_input) == expected
E AssertionError: assert 54 == 42
E + where 54 = eval('6*9')
test_expectation.py:8: AssertionError
==================== 1 failed, 2 passed in 0.12 seconds ====================
</pre></div>
</div>
<p>As designed in this example, only one pair of input/output values fails
the simple test function. And as usual with test function arguments,
you can see the <code class="docutils literal"><span class="pre">input</span></code> and <code class="docutils literal"><span class="pre">output</span></code> values in the traceback.</p>
<p>Note that you could also use the parametrize marker on a class or a module
(see <a class="reference internal" href="mark.html#mark"><span class="std std-ref">Marking test functions with attributes</span></a>) which would invoke several functions with the argument sets.</p>
<p>It is also possible to mark individual test instances within parametrize,
for example with the builtin <code class="docutils literal"><span class="pre">mark.xfail</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># content of test_expectation.py</span>
<span class="kn">import</span> <span class="nn">pytest</span>
<span class="nd">@pytest</span><span class="o">.</span><span class="n">mark</span><span class="o">.</span><span class="n">parametrize</span><span class="p">(</span><span class="s2">"test_input,expected"</span><span class="p">,</span> <span class="p">[</span>
<span class="p">(</span><span class="s2">"3+5"</span><span class="p">,</span> <span class="mi">8</span><span class="p">),</span>
<span class="p">(</span><span class="s2">"2+4"</span><span class="p">,</span> <span class="mi">6</span><span class="p">),</span>
<span class="n">pytest</span><span class="o">.</span><span class="n">param</span><span class="p">(</span><span class="s2">"6*9"</span><span class="p">,</span> <span class="mi">42</span><span class="p">,</span>
<span class="n">marks</span><span class="o">=</span><span class="n">pytest</span><span class="o">.</span><span class="n">mark</span><span class="o">.</span><span class="n">xfail</span><span class="p">),</span>
<span class="p">])</span>
<span class="k">def</span> <span class="nf">test_eval</span><span class="p">(</span><span class="n">test_input</span><span class="p">,</span> <span class="n">expected</span><span class="p">):</span>
<span class="k">assert</span> <span class="nb">eval</span><span class="p">(</span><span class="n">test_input</span><span class="p">)</span> <span class="o">==</span> <span class="n">expected</span>
</pre></div>
</div>
<p>Let's run this:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR, inifile:
collected 3 items
test_expectation.py ..x [100%]
=================== 2 passed, 1 xfailed in 0.12 seconds ====================
</pre></div>
</div>
<p>The one parameter set which caused a failure previously now
shows up as an "xfailed (expected to fail)" test.</p>
<p>To get all combinations of multiple parametrized arguments you can stack
<code class="docutils literal"><span class="pre">parametrize</span></code> decorators:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pytest</span>
<span class="nd">@pytest</span><span class="o">.</span><span class="n">mark</span><span class="o">.</span><span class="n">parametrize</span><span class="p">(</span><span class="s2">"x"</span><span class="p">,</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span>
<span class="nd">@pytest</span><span class="o">.</span><span class="n">mark</span><span class="o">.</span><span class="n">parametrize</span><span class="p">(</span><span class="s2">"y"</span><span class="p">,</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
<span class="k">def</span> <span class="nf">test_foo</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
<span class="k">pass</span>
</pre></div>
</div>
<p>This will run the test with the arguments set to <code class="docutils literal"><span class="pre">x=0/y=2</span></code>,``x=1/y=2``,
<code class="docutils literal"><span class="pre">x=0/y=3</span></code>, and <code class="docutils literal"><span class="pre">x=1/y=3</span></code> exhausting parameters in the order of the decorators.</p>
</div>
<div class="section" id="basic-pytest-generate-tests-example">
<span id="pytest-generate-tests"></span><h2>Basic <code class="docutils literal"><span class="pre">pytest_generate_tests</span></code> example<a class="headerlink" href="#basic-pytest-generate-tests-example" title="Permalink to this headline">¶</a></h2>
<p>Sometimes you may want to implement your own parametrization scheme
or implement some dynamism for determining the parameters or scope
of a fixture. For this, you can use the <code class="docutils literal"><span class="pre">pytest_generate_tests</span></code> hook
which is called when collecting a test function. Through the passed in
<code class="docutils literal"><span class="pre">metafunc</span></code> object you can inspect the requesting test context and, most
importantly, you can call <code class="docutils literal"><span class="pre">metafunc.parametrize()</span></code> to cause
parametrization.</p>
<p>For example, let's say we want to run a test taking string inputs which
we want to set via a new <code class="docutils literal"><span class="pre">pytest</span></code> command line option. Let's first write
a simple test accepting a <code class="docutils literal"><span class="pre">stringinput</span></code> fixture function argument:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># content of test_strings.py</span>
<span class="k">def</span> <span class="nf">test_valid_string</span><span class="p">(</span><span class="n">stringinput</span><span class="p">):</span>
<span class="k">assert</span> <span class="n">stringinput</span><span class="o">.</span><span class="n">isalpha</span><span class="p">()</span>
</pre></div>
</div>
<p>Now we add a <code class="docutils literal"><span class="pre">conftest.py</span></code> file containing the addition of a
command line option and the parametrization of our test function:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># content of conftest.py</span>
<span class="k">def</span> <span class="nf">pytest_addoption</span><span class="p">(</span><span class="n">parser</span><span class="p">):</span>
<span class="n">parser</span><span class="o">.</span><span class="n">addoption</span><span class="p">(</span><span class="s2">"--stringinput"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"append"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="p">[],</span>
<span class="n">help</span><span class="o">=</span><span class="s2">"list of stringinputs to pass to test functions"</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">pytest_generate_tests</span><span class="p">(</span><span class="n">metafunc</span><span class="p">):</span>
<span class="k">if</span> <span class="s1">'stringinput'</span> <span class="ow">in</span> <span class="n">metafunc</span><span class="o">.</span><span class="n">fixturenames</span><span class="p">:</span>
<span class="n">metafunc</span><span class="o">.</span><span class="n">parametrize</span><span class="p">(</span><span class="s2">"stringinput"</span><span class="p">,</span>
<span class="n">metafunc</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">getoption</span><span class="p">(</span><span class="s1">'stringinput'</span><span class="p">))</span>
</pre></div>
</div>
<p>If we now pass two stringinput values, our test will run twice:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ pytest -q --stringinput="hello" --stringinput="world" test_strings.py
.. [100%]
2 passed in 0.12 seconds
</pre></div>
</div>
<p>Let's also run with a stringinput that will lead to a failing test:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ pytest -q --stringinput="!" test_strings.py
F [100%]
================================= FAILURES =================================
___________________________ test_valid_string[!] ___________________________
stringinput = '!'
def test_valid_string(stringinput):
> assert stringinput.isalpha()
E AssertionError: assert False
E + where False = <built-in method isalpha of str object at 0xdeadbeef>()
E + where <built-in method isalpha of str object at 0xdeadbeef> = '!'.isalpha
test_strings.py:3: AssertionError
1 failed in 0.12 seconds
</pre></div>
</div>
<p>As expected our test function fails.</p>
<p>If you don't specify a stringinput it will be skipped because
<code class="docutils literal"><span class="pre">metafunc.parametrize()</span></code> will be called with an empty parameter
list:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ pytest -q -rs test_strings.py
s [100%]
========================= short test summary info ==========================
SKIP [1] test_strings.py: got empty parameter set ['stringinput'], function test_valid_string at $REGENDOC_TMPDIR/test_strings.py:1
1 skipped in 0.12 seconds
</pre></div>
</div>
<p>Note that when calling <code class="docutils literal"><span class="pre">metafunc.parametrize</span></code> multiple times with different parameter sets, all parameter names across
those sets cannot be duplicated, otherwise an error will be raised.</p>
</div>
<div class="section" id="more-examples">
<h2>More examples<a class="headerlink" href="#more-examples" title="Permalink to this headline">¶</a></h2>
<p>For further examples, you might want to look at <a class="reference internal" href="example/parametrize.html#paramexamples"><span class="std std-ref">more
parametrization examples</span></a>.</p>
</div>
<div class="section" id="the-metafunc-object">
<span id="metafunc-object"></span><h2>The <strong>metafunc</strong> object<a class="headerlink" href="#the-metafunc-object" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="_pytest.python.Metafunc">
<em class="property">class </em><code class="descname">Metafunc</code><span class="sig-paren">(</span><em>function</em>, <em>fixtureinfo</em>, <em>config</em>, <em>cls=None</em>, <em>module=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/_pytest/python.html#Metafunc"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.Metafunc" title="Permalink to this definition">¶</a></dt>
<dd><p>Metafunc objects are passed to the <code class="docutils literal"><span class="pre">pytest_generate_tests</span></code> hook.
They help to inspect a test function and to generate tests according to
test configuration or values specified in the class or module where a
test function is defined.</p>
<dl class="attribute">
<dt id="_pytest.python.Metafunc.config">
<code class="descname">config</code><em class="property"> = None</em><a class="headerlink" href="#_pytest.python.Metafunc.config" title="Permalink to this definition">¶</a></dt>
<dd><p>access to the <a class="reference internal" href="writing_plugins.html#_pytest.config.Config" title="_pytest.config.Config"><code class="xref py py-class docutils literal"><span class="pre">_pytest.config.Config</span></code></a> object for the test session</p>
</dd></dl>
<dl class="attribute">
<dt id="_pytest.python.Metafunc.module">
<code class="descname">module</code><em class="property"> = None</em><a class="headerlink" href="#_pytest.python.Metafunc.module" title="Permalink to this definition">¶</a></dt>
<dd><p>the module object where the test function is defined in.</p>
</dd></dl>
<dl class="attribute">
<dt id="_pytest.python.Metafunc.function">
<code class="descname">function</code><em class="property"> = None</em><a class="headerlink" href="#_pytest.python.Metafunc.function" title="Permalink to this definition">¶</a></dt>
<dd><p>underlying python test function</p>
</dd></dl>
<dl class="attribute">
<dt id="_pytest.python.Metafunc.fixturenames">
<code class="descname">fixturenames</code><em class="property"> = None</em><a class="headerlink" href="#_pytest.python.Metafunc.fixturenames" title="Permalink to this definition">¶</a></dt>
<dd><p>set of fixture names required by the test function</p>
</dd></dl>
<dl class="attribute">
<dt id="_pytest.python.Metafunc.cls">
<code class="descname">cls</code><em class="property"> = None</em><a class="headerlink" href="#_pytest.python.Metafunc.cls" title="Permalink to this definition">¶</a></dt>
<dd><p>class object where the test function is defined in or <code class="docutils literal"><span class="pre">None</span></code>.</p>
</dd></dl>
<dl class="method">
<dt id="_pytest.python.Metafunc.parametrize">
<code class="descname">parametrize</code><span class="sig-paren">(</span><em>argnames</em>, <em>argvalues</em>, <em>indirect=False</em>, <em>ids=None</em>, <em>scope=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/_pytest/python.html#Metafunc.parametrize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.Metafunc.parametrize" title="Permalink to this definition">¶</a></dt>
<dd><p>Add new invocations to the underlying test function using the list
of argvalues for the given argnames. Parametrization is performed
during the collection phase. If you need to setup expensive resources
see about setting indirect to do it rather at test setup time.</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>argnames</strong> -- a comma-separated string denoting one or more argument
names, or a list/tuple of argument strings.</li>
<li><strong>argvalues</strong> -- The list of argvalues determines how often a
test is invoked with different argument values. If only one
argname was specified argvalues is a list of values. If N
argnames were specified, argvalues must be a list of N-tuples,
where each tuple-element specifies a value for its respective
argname.</li>
<li><strong>indirect</strong> -- The list of argnames or boolean. A list of arguments'
names (subset of argnames). If True the list contains all names from
the argnames. Each argvalue corresponding to an argname in this list will
be passed as request.param to its respective argname fixture
function so that it can perform more expensive setups during the
setup phase of a test rather than at collection time.</li>
<li><strong>ids</strong> -- list of string ids, or a callable.
If strings, each is corresponding to the argvalues so that they are
part of the test id. If None is given as id of specific test, the
automatically generated id for that argument will be used.
If callable, it should take one argument (a single argvalue) and return
a string or return None. If None, the automatically generated id for that
argument will be used.
If no ids are provided they will be generated automatically from
the argvalues.</li>
<li><strong>scope</strong> -- if specified it denotes the scope of the parameters.
The scope is used for grouping tests by parameter instances.
It will also override any fixture-function defined scope, allowing
to set a dynamic scope using test context or configuration.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="_pytest.python.Metafunc.addcall">
<code class="descname">addcall</code><span class="sig-paren">(</span><em>funcargs=None</em>, <em>id=<object object></em>, <em>param=<object object></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/_pytest/python.html#Metafunc.addcall"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.Metafunc.addcall" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a new call to the underlying test function during the collection phase of a test run.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.3: </span>Use <a class="reference internal" href="#_pytest.python.Metafunc.parametrize" title="_pytest.python.Metafunc.parametrize"><code class="xref py py-meth docutils literal"><span class="pre">parametrize()</span></code></a> instead.</p>
</div>
<p>Note that request.addcall() is called during the test collection phase prior and
independently to actual test execution. You should only use addcall()
if you need to specify multiple arguments of a test 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 last simple">
<li><strong>funcargs</strong> -- argument keyword dictionary used when invoking
the test function.</li>
<li><strong>id</strong> -- used for reporting and identification purposes. If you
don't supply an <cite>id</cite> an automatic unique id will be generated.</li>
<li><strong>param</strong> -- a parameter which will be exposed to a later fixture function
invocation through the <code class="docutils literal"><span class="pre">request.param</span></code> attribute.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="contents.html">
<img class="logo" src="_static/pytest1.png" alt="Logo"/>
</a></p><h3><a href="contents.html">Table Of Contents</a></h3>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="contents.html">Contents</a></li>
<li><a href="getting-started.html">Install</a></li>
<li><a href="example/index.html">Examples</a></li>
<li><a href="customize.html">Customize</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="talks.html">Talks/Posts</a></li>
<li><a href="changelog.html">Changelog</a></li>
<li><a href="backwards-compatibility.html">Backwards Compatibility</a></li>
<li><a href="license.html">License</a></li>
</ul>
<hr>
<ul>
<li><a class="reference internal" href="#">Parametrizing fixtures and test functions</a><ul>
<li><a class="reference internal" href="#pytest-mark-parametrize-parametrizing-test-functions"><code class="docutils literal"><span class="pre">@pytest.mark.parametrize</span></code>: parametrizing test functions</a></li>
<li><a class="reference internal" href="#basic-pytest-generate-tests-example">Basic <code class="docutils literal"><span class="pre">pytest_generate_tests</span></code> example</a></li>
<li><a class="reference internal" href="#more-examples">More examples</a></li>
<li><a class="reference internal" href="#the-metafunc-object">The <strong>metafunc</strong> object</a></li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
<li><a href="contents.html">Documentation overview</a><ul>
<li>Previous: <a href="skipping.html" title="previous chapter">Skip and xfail: dealing with tests that cannot succeed</a></li>
<li>Next: <a href="cache.html" title="next chapter">Cache: working with cross-testrun state</a></li>
</ul></li>
</ul><h3>Useful Links</h3>
<ul>
<li><a href="index.html">The pytest Website</a></li>
<li><a href="contributing.html">Contribution Guide</a></li>
<li><a href="https://pypi.python.org/pypi/pytest">pytest @ PyPI</a></li>
<li><a href="https://github.com/pytest-dev/pytest/">pytest @ GitHub</a></li>
<li><a href="http://plugincompat.herokuapp.com/">3rd party plugins</a></li>
<li><a href="https://github.com/pytest-dev/pytest/issues">Issue Tracker</a></li>
<li><a href="https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf">PDF Documentation</a>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
© Copyright 2018, holger krekel and pytest-dev team.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
</div>
</body>
</html>
|