Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > media > contrib-backports > by-pkgid > 85556a06d0b40546e6bb4676359ced2e > files > 193

python-pytest-2.2.4-1mdv2010.1.noarch.rpm



<!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>Injecting objects into test functions (funcargs)</title>
    <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '2.2.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="None" href="index.html" />
    <link rel="up" title="py.test reference documentation" href="apiref.html" />
    <link rel="next" title="Extended xUnit style setup fixtures" href="xunit_setup.html" />
    <link rel="prev" title="The writing and reporting of assertions in tests" href="assert.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a></li>
        <li class="right" >
          <a href="xunit_setup.html" title="Extended xUnit style setup fixtures"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="assert.html" title="The writing and reporting of assertions in tests"
             accesskey="P">previous</a> |</li>
        <li><a href="contents.html">pytest-2.2.4</a> &raquo;</li>
          <li><a href="apiref.html" accesskey="U">py.test reference documentation</a> &raquo;</li>
 
<g:plusone></g:plusone>

      </ul>
    </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Search" />
      <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>

<h3>quicklinks</h3>
<div style="text-align: left; font-size: 100%; vertical-align: middle;">
<table>
<tr>
<td>
        <a href="index.html">home</a>
</td><td>
        <a href="contents.html">TOC/contents</a>
</td></tr><tr><td>
        <a href="getting-started.html">install</a>
</td><td>
        <a href="changelog.html">changelog</a>
</td></tr><tr><td>
        <a href="example/index.html">examples</a>
</td><td>
        <a href="customize.html">customize</a>
</td></tr><tr><td>
        <a href="https://bitbucket.org/hpk42/pytest/issues?status=new&status=open">issues[bb]</a>
</td><td>
        <a href="contact.html">contact</a>
</td></tr></table>
</div>

  <h3><a href="contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Injecting objects into test functions (funcargs)</a><ul>
<li><a class="reference internal" href="#dependency-injection-through-function-arguments">Dependency injection through function arguments</a><ul>
<li><a class="reference internal" href="#basic-injection-example">Basic injection example</a></li>
</ul>
</li>
<li><a class="reference internal" href="#the-funcarg-request-object">The funcarg <strong>request</strong> object</a></li>
<li><a class="reference internal" href="#parametrizing-multiple-calls-to-a-test-function">Parametrizing multiple calls to a test function</a><ul>
<li><a class="reference internal" href="#basic-generated-test-example">Basic generated test example</a></li>
<li><a class="reference internal" href="#the-metafunc-object">The <strong>metafunc</strong> object</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="assert.html"
                        title="previous chapter">The writing and reporting of assertions in tests</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="xunit_setup.html"
                        title="next chapter">Extended xUnit style setup fixtures</a></p>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="injecting-objects-into-test-functions-funcargs">
<h1>Injecting objects into test functions (funcargs)<a class="headerlink" href="#injecting-objects-into-test-functions-funcargs" title="Permalink to this headline">¶</a></h1>
<div class="section" id="dependency-injection-through-function-arguments">
<span id="funcarg-mechanism"></span><span id="funcargs"></span><h2>Dependency injection through function arguments<a class="headerlink" href="#dependency-injection-through-function-arguments" title="Permalink to this headline">¶</a></h2>
<p>py.test lets you inject objects into test functions and precisely
control their life cycle in relation to the test execution. It is
also possible to run a test function multiple times with different objects.</p>
<p>The basic mechanism for injecting objects is also called the
<em>funcarg mechanism</em> because objects are ultimately injected
by calling a test function with it as an argument.  Unlike the
classical xUnit approach <em>funcargs</em> relate more to <a class="reference external" href="http://en.wikipedia.org/wiki/Dependency_injection">Dependency Injection</a>
because they help to de-couple test code from objects required for
them to execute.</p>
<p>To create a value with which to call a test function a factory function
is called which gets full access to the test function context and can
register finalizers or invoke lifecycle-caching helpers.  The factory
can be implemented in same test class or test module, or in a
per-directory <tt class="docutils literal"><span class="pre">conftest.py</span></tt> file or even in an external plugin.  This
allows full de-coupling of test code and objects needed for test
execution.</p>
<p>A test function may be invoked multiple times in which case we
speak of <a class="reference internal" href="#parametrizing-tests"><em>parametrized testing</em></a>. This can be
very useful if you want to test e.g. against different database backends
or with multiple numerical arguments sets and want to reuse the same set
of test functions.</p>
<p>py.test comes with <a class="reference internal" href="builtin.html#builtinfuncargs"><em>Builtin function arguments</em></a> and there are some refined usages in the examples section.</p>
<div class="section" id="basic-injection-example">
<span id="funcarg"></span><h3>Basic injection example<a class="headerlink" href="#basic-injection-example" title="Permalink to this headline">¶</a></h3>
<p>Let&#8217;s look at a simple self-contained test module:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># content of ./test_simplefactory.py</span>
<span class="k">def</span> <span class="nf">pytest_funcarg__myfuncarg</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
    <span class="k">return</span> <span class="mi">42</span>

<span class="k">def</span> <span class="nf">test_function</span><span class="p">(</span><span class="n">myfuncarg</span><span class="p">):</span>
    <span class="k">assert</span> <span class="n">myfuncarg</span> <span class="o">==</span> <span class="mi">17</span>
</pre></div>
</div>
<p>This test function needs an injected object named <tt class="docutils literal"><span class="pre">myfuncarg</span></tt>.
py.test will discover and call the factory named
<tt class="docutils literal"><span class="pre">pytest_funcarg__myfuncarg</span></tt> within the same module in this case.</p>
<p>Running the test looks like this:</p>
<div class="highlight-python"><pre>$ py.test test_simplefactory.py
=========================== test session starts ============================
platform darwin -- Python 2.7.1 -- pytest-2.2.2
collecting ... collected 1 items

test_simplefactory.py F

================================= FAILURES =================================
______________________________ test_function _______________________________

myfuncarg = 42

    def test_function(myfuncarg):
&gt;       assert myfuncarg == 17
E       assert 42 == 17

test_simplefactory.py:5: AssertionError
========================= 1 failed in 0.03 seconds =========================</pre>
</div>
<p>This means that indeed the test function was called with a <tt class="docutils literal"><span class="pre">myfuncarg</span></tt>
argument value of <tt class="docutils literal"><span class="pre">42</span></tt> and the assert fails.  Here is how py.test
comes to call the test function this way:</p>
<ol class="arabic simple">
<li>py.test <a class="reference internal" href="goodpractises.html#test-discovery"><em>finds</em></a> the <tt class="docutils literal"><span class="pre">test_function</span></tt> because
of the <tt class="docutils literal"><span class="pre">test_</span></tt> prefix.  The test function needs a function argument
named <tt class="docutils literal"><span class="pre">myfuncarg</span></tt>.  A matching factory function is discovered by
looking for the name <tt class="docutils literal"><span class="pre">pytest_funcarg__myfuncarg</span></tt>.</li>
<li><tt class="docutils literal"><span class="pre">pytest_funcarg__myfuncarg(request)</span></tt> is called and
returns the value for <tt class="docutils literal"><span class="pre">myfuncarg</span></tt>.</li>
<li>the test function can now be called: <tt class="docutils literal"><span class="pre">test_function(42)</span></tt>.
This results in the above exception because of the assertion
mismatch.</li>
</ol>
<p>Note that if you misspell a function argument or want
to use one that isn&#8217;t available, you&#8217;ll see an error
with a list of available function arguments.</p>
<p>You can always issue:</p>
<div class="highlight-python"><pre>py.test --funcargs test_simplefactory.py</pre>
</div>
<p>to see available function arguments (which you can also
think of as &#8220;resources&#8221;).</p>
</div>
</div>
<div class="section" id="the-funcarg-request-object">
<span id="factory"></span><span id="funcarg-factory"></span><h2>The funcarg <strong>request</strong> object<a class="headerlink" href="#the-funcarg-request-object" title="Permalink to this headline">¶</a></h2>
<p>Each funcarg factory receives a <strong>request</strong> object tied to a specific test
function call.  A request object is passed to a funcarg factory and provides
access to test configuration and context:</p>
<dl class="class">
<dt id="_pytest.python.FuncargRequest">
<em class="property">class </em><tt class="descclassname">_pytest.python.</tt><tt class="descname">FuncargRequest</tt><a class="reference internal" href="_modules/_pytest/python.html#FuncargRequest"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.FuncargRequest" title="Permalink to this definition">¶</a></dt>
<dd><p>A request for function arguments from a test function.</p>
<p>Note that there is an optional <tt class="docutils literal"><span class="pre">param</span></tt> attribute in case
there was an invocation to metafunc.addcall(param=...).
If no such call was done in a <tt class="docutils literal"><span class="pre">pytest_generate_tests</span></tt>
hook, the attribute will not be present.</p>
<dl class="attribute">
<dt id="_pytest.python.FuncargRequest.function">
<tt class="descname">function</tt><a class="reference internal" href="_modules/_pytest/python.html#FuncargRequest.function"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.FuncargRequest.function" title="Permalink to this definition">¶</a></dt>
<dd><p>function object of the test invocation.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.python.FuncargRequest.cls">
<tt class="descname">cls</tt><a class="reference internal" href="_modules/_pytest/python.html#FuncargRequest.cls"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.FuncargRequest.cls" title="Permalink to this definition">¶</a></dt>
<dd><p>class (can be None) where the test function was collected.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.python.FuncargRequest.module">
<tt class="descname">module</tt><a class="reference internal" href="_modules/_pytest/python.html#FuncargRequest.module"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.FuncargRequest.module" title="Permalink to this definition">¶</a></dt>
<dd><p>module where the test function was collected.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.python.FuncargRequest.keywords">
<tt class="descname">keywords</tt><a class="reference internal" href="_modules/_pytest/python.html#FuncargRequest.keywords"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.FuncargRequest.keywords" title="Permalink to this definition">¶</a></dt>
<dd><p>keywords of the test function item.</p>
<p class="versionadded">
<span class="versionmodified">New in version 2.0.</span></p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.python.FuncargRequest.config">
<tt class="descname">config</tt><a class="reference internal" href="_modules/_pytest/python.html#FuncargRequest.config"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.FuncargRequest.config" title="Permalink to this definition">¶</a></dt>
<dd><p>the pytest config object associated with this request.</p>
</dd></dl>

</dd></dl>

<span class="target" id="useful-caching-and-finalization-helpers"></span><dl class="method">
<dt id="_pytest.python.FuncargRequest.addfinalizer">
<tt class="descclassname">FuncargRequest.</tt><tt class="descname">addfinalizer</tt><big>(</big><em>finalizer</em><big>)</big><a class="reference internal" href="_modules/_pytest/python.html#FuncargRequest.addfinalizer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.FuncargRequest.addfinalizer" title="Permalink to this definition">¶</a></dt>
<dd><p>add finalizer function to be called after test function
finished execution.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.python.FuncargRequest.cached_setup">
<tt class="descclassname">FuncargRequest.</tt><tt class="descname">cached_setup</tt><big>(</big><em>setup</em>, <em>teardown=None</em>, <em>scope='module'</em>, <em>extrakey=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/python.html#FuncargRequest.cached_setup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.FuncargRequest.cached_setup" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a testing resource managed by <tt class="docutils literal"><span class="pre">setup</span></tt> &amp;
<tt class="docutils literal"><span class="pre">teardown</span></tt> calls.  <tt class="docutils literal"><span class="pre">scope</span></tt> and <tt class="docutils literal"><span class="pre">extrakey</span></tt> determine when the
<tt class="docutils literal"><span class="pre">teardown</span></tt> function will be called so that subsequent calls to
<tt class="docutils literal"><span class="pre">setup</span></tt> would recreate the resource.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>teardown</strong> &#8211; function receiving a previously setup resource.</li>
<li><strong>setup</strong> &#8211; a no-argument function creating a resource.</li>
<li><strong>scope</strong> &#8211; a string value out of <tt class="docutils literal"><span class="pre">function</span></tt>, <tt class="docutils literal"><span class="pre">class</span></tt>, <tt class="docutils literal"><span class="pre">module</span></tt>
or <tt class="docutils literal"><span class="pre">session</span></tt> indicating the caching lifecycle of the resource.</li>
<li><strong>extrakey</strong> &#8211; added to internal caching key of (funcargname, scope).</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="_pytest.python.FuncargRequest.applymarker">
<tt class="descclassname">FuncargRequest.</tt><tt class="descname">applymarker</tt><big>(</big><em>marker</em><big>)</big><a class="reference internal" href="_modules/_pytest/python.html#FuncargRequest.applymarker"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.FuncargRequest.applymarker" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply a marker to a single test function invocation.
This method is useful if you don&#8217;t want to have a keyword/marker
on all function invocations.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><strong>marker</strong> &#8211; a <a class="reference internal" href="mark.html#_pytest.mark.MarkDecorator" title="_pytest.mark.MarkDecorator"><tt class="xref py py-class docutils literal"><span class="pre">_pytest.mark.MarkDecorator</span></tt></a> object
created by a call to <tt class="docutils literal"><span class="pre">py.test.mark.NAME(...)</span></tt>.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="_pytest.python.FuncargRequest.getfuncargvalue">
<tt class="descclassname">FuncargRequest.</tt><tt class="descname">getfuncargvalue</tt><big>(</big><em>argname</em><big>)</big><a class="reference internal" href="_modules/_pytest/python.html#FuncargRequest.getfuncargvalue"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.FuncargRequest.getfuncargvalue" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve a function argument by name for this test
function invocation.  This allows one function argument factory
to call another function argument factory.  If there are two
funcarg factories for the same test function argument the first
factory may use <tt class="docutils literal"><span class="pre">getfuncargvalue</span></tt> to call the second one and
do something additional with the resource.</p>
</dd></dl>

</div>
<div class="section" id="parametrizing-multiple-calls-to-a-test-function">
<span id="parametrized-test-functions"></span><span id="parametrizing-tests"></span><span id="test-generators"></span><h2>Parametrizing multiple calls to a test function<a class="headerlink" href="#parametrizing-multiple-calls-to-a-test-function" title="Permalink to this headline">¶</a></h2>
<p>You can parametrize multiple runs of the same test
function by adding new test function calls with different
function argument values. Let&#8217;s look at a simple self-contained
example:</p>
<div class="section" id="basic-generated-test-example">
<h3>Basic generated test example<a class="headerlink" href="#basic-generated-test-example" title="Permalink to this headline">¶</a></h3>
<p>Let&#8217;s consider a test module which uses the <tt class="docutils literal"><span class="pre">pytest_generate_tests</span></tt>
hook to generate several calls to the same test function:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># content of test_example.py</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="s">&quot;numiter&quot;</span> <span class="ow">in</span> <span class="n">metafunc</span><span class="o">.</span><span class="n">funcargnames</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="s">&quot;numiter&quot;</span><span class="p">,</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">))</span>

<span class="k">def</span> <span class="nf">test_func</span><span class="p">(</span><span class="n">numiter</span><span class="p">):</span>
    <span class="k">assert</span> <span class="n">numiter</span> <span class="o">&lt;</span> <span class="mi">9</span>
</pre></div>
</div>
<p>Running this will generate ten invocations of <tt class="docutils literal"><span class="pre">test_func</span></tt> passing in each of the items in the list of <tt class="docutils literal"><span class="pre">range(10)</span></tt>:</p>
<div class="highlight-python"><pre>$ py.test test_example.py
=========================== test session starts ============================
platform darwin -- Python 2.7.1 -- pytest-2.2.2
collecting ... collected 10 items

test_example.py .........F

================================= FAILURES =================================
_______________________________ test_func[9] _______________________________

numiter = 9

    def test_func(numiter):
&gt;       assert numiter &lt; 9
E       assert 9 &lt; 9

test_example.py:6: AssertionError
==================== 1 failed, 9 passed in 0.07 seconds ====================</pre>
</div>
<p>Obviously, only when <tt class="docutils literal"><span class="pre">numiter</span></tt> has the value of <tt class="docutils literal"><span class="pre">9</span></tt> does the test fail.  Note that the <tt class="docutils literal"><span class="pre">pytest_generate_tests(metafunc)</span></tt> hook is called during
the test collection phase which is separate from the actual test running.
Let&#8217;s just look at what is collected:</p>
<div class="highlight-python"><pre>$ py.test --collectonly test_example.py
=========================== test session starts ============================
platform darwin -- Python 2.7.1 -- pytest-2.2.2
collecting ... collected 10 items
&lt;Module 'test_example.py'&gt;
  &lt;Function 'test_func[0]'&gt;
  &lt;Function 'test_func[1]'&gt;
  &lt;Function 'test_func[2]'&gt;
  &lt;Function 'test_func[3]'&gt;
  &lt;Function 'test_func[4]'&gt;
  &lt;Function 'test_func[5]'&gt;
  &lt;Function 'test_func[6]'&gt;
  &lt;Function 'test_func[7]'&gt;
  &lt;Function 'test_func[8]'&gt;
  &lt;Function 'test_func[9]'&gt;

=============================  in 0.01 seconds =============================</pre>
</div>
<p>If you want to select only the run with the value <tt class="docutils literal"><span class="pre">7</span></tt> you could do:</p>
<div class="highlight-python"><pre>$ py.test -v -k 7 test_example.py  # or -k test_func[7]
=========================== test session starts ============================
platform darwin -- Python 2.7.1 -- pytest-2.2.2 -- /Users/hpk/venv/0/bin/python
collecting ... collected 10 items

test_example.py:5: test_func[7] PASSED

======================= 9 tests deselected by '-k7' ========================
================== 1 passed, 9 deselected in 0.01 seconds ==================</pre>
</div>
<p>You might want to look at <a class="reference internal" href="example/parametrize.html#paramexamples"><em>more parametrization examples</em></a>.</p>
</div>
<div class="section" id="the-metafunc-object">
<span id="metafunc-object"></span><h3>The <strong>metafunc</strong> object<a class="headerlink" href="#the-metafunc-object" title="Permalink to this headline">¶</a></h3>
<p>metafunc objects are passed to the <tt class="docutils literal"><span class="pre">pytest_generate_tests</span></tt> hook.
They help to inspect a testfunction and to generate tests
according to test configuration or values specified
in the class or module where a test function is defined:</p>
<p><tt class="docutils literal"><span class="pre">metafunc.funcargnames</span></tt>: set of required function arguments for given function</p>
<p><tt class="docutils literal"><span class="pre">metafunc.function</span></tt>: underlying python test function</p>
<p><tt class="docutils literal"><span class="pre">metafunc.cls</span></tt>: class object where the test function is defined in or None.</p>
<p><tt class="docutils literal"><span class="pre">metafunc.module</span></tt>: the module object where the test function is defined in.</p>
<p><tt class="docutils literal"><span class="pre">metafunc.config</span></tt>: access to command line opts and general config</p>
<dl class="method">
<dt id="_pytest.python.Metafunc.parametrize">
<tt class="descclassname">Metafunc.</tt><tt class="descname">parametrize</tt><big>(</big><em>argnames</em>, <em>argvalues</em>, <em>indirect=False</em>, <em>ids=None</em><big>)</big><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
you may pass indirect=True and implement a funcarg factory which can
perform the expensive setup just before a test is actually run.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>argnames</strong> &#8211; an argument name or a list of argument names</li>
<li><strong>argvalues</strong> &#8211; a list of values for the argname or a list of tuples of
values for the list of argument names.</li>
<li><strong>indirect</strong> &#8211; if True each argvalue corresponding to an argument will
be passed as request.param to its respective funcarg factory 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> &#8211; list of string ids each corresponding to the argvalues so
that they are part of the test id. If no ids are provided they will
be generated automatically from the argvalues.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="_pytest.python.Metafunc.addcall">
<tt class="descclassname">Metafunc.</tt><tt class="descname">addcall</tt><big>(</big><em>funcargs=None</em>, <em>id=_notexists</em>, <em>param=_notexists</em><big>)</big><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>(deprecated, use parametrize) Add a new call to the underlying
test function during the collection phase of a test run.  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"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>funcargs</strong> &#8211; argument keyword dictionary used when invoking
the test function.</li>
<li><strong>id</strong> &#8211; used for reporting and identification purposes.  If you
don&#8217;t supply an <cite>id</cite> an automatic unique id will be generated.</li>
<li><strong>param</strong> &#8211; a parameter which will be exposed to a later funcarg factory
invocation through the <tt class="docutils literal"><span class="pre">request.param</span></tt> attribute.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a></li>
        <li class="right" >
          <a href="xunit_setup.html" title="Extended xUnit style setup fixtures"
             >next</a> |</li>
        <li class="right" >
          <a href="assert.html" title="The writing and reporting of assertions in tests"
             >previous</a> |</li>
        <li><a href="contents.html">pytest-2.2.4</a> &raquo;</li>
          <li><a href="apiref.html" >py.test reference documentation</a> &raquo;</li>
 
<g:plusone></g:plusone>

      </ul>
    </div>

    <div class="footer">
        &copy; Copyright 2011, holger krekel et alii.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-7597274-13']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>

  </body>
</html>