Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > c004b048a08dced45cdde088d7d8ef62 > files > 261

pytest-2.3.5-3.fc18.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>Working with plugins and conftest files</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.3.4.1',
        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="next" title="Usages and Examples" href="example/index.html" />
    <link rel="prev" title="Doctest integration for modules and test files" href="doctest.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="example/index.html" title="Usages and Examples"
             accesskey="N">next</a></li>
        <li class="right" >
          <a href="doctest.html" title="Doctest integration for modules and test files"
             accesskey="P">previous</a> |</li>
        <li><a href="contents.html">pytest-2.3.4.1</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="#">Working with plugins and conftest files</a><ul>
<li><a class="reference internal" href="#conftest-py-local-per-directory-plugins">conftest.py: local per-directory plugins</a></li>
<li><a class="reference internal" href="#installing-external-plugins-searching">Installing External Plugins / Searching</a></li>
<li><a class="reference internal" href="#writing-a-plugin-by-looking-at-examples">Writing a plugin by looking at examples</a></li>
<li><a class="reference internal" href="#making-your-plugin-installable-by-others">Making your plugin installable by others</a></li>
<li><a class="reference internal" href="#plugin-discovery-order-at-tool-startup">Plugin discovery order at tool startup</a></li>
<li><a class="reference internal" href="#requiring-loading-plugins-in-a-test-module-or-conftest-file">Requiring/Loading plugins in a test module or conftest file</a></li>
<li><a class="reference internal" href="#accessing-another-plugin-by-name">Accessing another plugin by name</a></li>
<li><a class="reference internal" href="#finding-out-which-plugins-are-active">Finding out which plugins are active</a></li>
<li><a class="reference internal" href="#deactivating-unregistering-a-plugin-by-name">Deactivating / unregistering a plugin by name</a></li>
</ul>
</li>
<li><a class="reference internal" href="#py-test-default-plugin-reference">py.test default plugin reference</a></li>
<li><a class="reference internal" href="#py-test-hook-reference">py.test hook reference</a><ul>
<li><a class="reference internal" href="#hook-specification-and-validation">Hook specification and validation</a></li>
<li><a class="reference internal" href="#initialization-command-line-and-configuration-hooks">Initialization, command line and configuration hooks</a></li>
<li><a class="reference internal" href="#generic-runtest-hooks">Generic &#8220;runtest&#8221; hooks</a></li>
<li><a class="reference internal" href="#collection-hooks">Collection hooks</a></li>
<li><a class="reference internal" href="#reporting-hooks">Reporting hooks</a></li>
</ul>
</li>
<li><a class="reference internal" href="#reference-of-objects-involved-in-hooks">Reference of objects involved in hooks</a></li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="doctest.html"
                        title="previous chapter">Doctest integration for modules and test files</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="example/index.html"
                        title="next chapter">Usages and Examples</a></p>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="working-with-plugins-and-conftest-files">
<span id="plugins"></span><h1>Working with plugins and conftest files<a class="headerlink" href="#working-with-plugins-and-conftest-files" title="Permalink to this headline">¶</a></h1>
<p>py.test implements all aspects of configuration, collection, running and reporting by calling <a class="reference internal" href="#well-specified-hooks">well specified hooks</a>.  Virtually any Python module can be registered as a plugin.  It can implement any number of hook functions (usually two or three) which all have a <tt class="docutils literal"><span class="pre">pytest_</span></tt> prefix, making hook functions easy to distinguish and find.  There are three basic location types:</p>
<ul class="simple">
<li><a class="reference internal" href="#builtin-plugins">builtin plugins</a>: loaded from py.test&#8217;s internal <tt class="docutils literal"><span class="pre">_pytest</span></tt> directory.</li>
<li><a class="reference internal" href="#external-plugins">external plugins</a>: modules discovered through <a class="reference internal" href="#setuptools-entry-points">setuptools entry points</a></li>
<li><a class="reference internal" href="#conftest-py-plugins">conftest.py plugins</a>: modules auto-discovered in test directories</li>
</ul>
<div class="section" id="conftest-py-local-per-directory-plugins">
<span id="conftest"></span><span id="localplugin"></span><span id="conftest-py"></span><span id="conftest-py-plugins"></span><h2>conftest.py: local per-directory plugins<a class="headerlink" href="#conftest-py-local-per-directory-plugins" title="Permalink to this headline">¶</a></h2>
<p>local <tt class="docutils literal"><span class="pre">conftest.py</span></tt> plugins contain directory-specific hook
implementations.  Session and test running activities will
invoke all hooks defined in <tt class="docutils literal"><span class="pre">conftest.py</span></tt> files closer to the
root of the filesystem.  Example: Assume the following layout
and content of files:</p>
<div class="highlight-python"><pre>a/conftest.py:
    def pytest_runtest_setup(item):
        # called for running each test in 'a' directory
        print ("setting up", item)

a/test_in_subdir.py:
    def test_sub():
        pass

test_flat.py:
    def test_flat():
        pass</pre>
</div>
<p>Here is how you might run it:</p>
<div class="highlight-python"><pre>py.test test_flat.py   # will not show "setting up"
py.test a/test_sub.py  # will show "setting up"</pre>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you have <tt class="docutils literal"><span class="pre">conftest.py</span></tt> files which do not reside in a
python package directory (i.e. one containing an <tt class="docutils literal"><span class="pre">__init__.py</span></tt>) then
&#8220;import conftest&#8221; can be ambiguous because there might be other
<tt class="docutils literal"><span class="pre">conftest.py</span></tt> files as well on your PYTHONPATH or <tt class="docutils literal"><span class="pre">sys.path</span></tt>.
It is thus good practise for projects to either put <tt class="docutils literal"><span class="pre">conftest.py</span></tt>
under a package scope or to never import anything from a
conftest.py file.</p>
</div>
</div>
<div class="section" id="installing-external-plugins-searching">
<span id="extplugins"></span><span id="external-plugins"></span><h2>Installing External Plugins / Searching<a class="headerlink" href="#installing-external-plugins-searching" title="Permalink to this headline">¶</a></h2>
<p>Installing a plugin happens through any usual Python installation
tool, for example:</p>
<div class="highlight-python"><pre>pip install pytest-NAME
pip uninstall pytest-NAME</pre>
</div>
<p>If a plugin is installed,  py.test automatically finds and integrates it,
there is no need to activate it.  Here is a initial list of known plugins:</p>
<ul class="simple">
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-django">pytest-django</a>: write tests
for <a class="reference external" href="https://www.djangoproject.com/">django</a> apps, using pytest integration.</li>
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-twisted">pytest-twisted</a>: write tests
for <a class="reference external" href="http://twistedmatrix.com">twisted</a> apps, starting a reactor and
processing deferreds from test functions.</li>
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-capturelog">pytest-capturelog</a>:
to capture and assert about messages from the logging module</li>
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-xdist">pytest-xdist</a>:
to distribute tests to CPUs and remote hosts, to run in boxed
mode which allows to survive segmentation faults, to run in
looponfailing mode, automatically re-running failing tests
on file changes, see also <a class="reference internal" href="xdist.html#xdist"><em>xdist: pytest distributed testing plugin</em></a></li>
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-timeout">pytest-timeout</a>:
to timeout tests based on function marks or global definitions.</li>
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-cache">pytest-cache</a>:
to interactively re-run failing tests and help other plugins to
store test run information across invocations.</li>
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-cov">pytest-cov</a>:
coverage reporting, compatible with distributed testing</li>
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-pep8">pytest-pep8</a>:
a <tt class="docutils literal"><span class="pre">--pep8</span></tt> option to enable PEP8 compliance checking.</li>
<li><a class="reference external" href="http://pypi.python.org/pypi/oejskit">oejskit</a>:
a plugin to run javascript unittests in life browsers</li>
</ul>
<p>You may discover more plugins through a <a class="reference external" href="http://pypi.python.org/pypi?%3Aaction=search&amp;term=pytest-&amp;submit=search">pytest- pypi.python.org search</a>.</p>
</div>
<div class="section" id="writing-a-plugin-by-looking-at-examples">
<h2>Writing a plugin by looking at examples<a class="headerlink" href="#writing-a-plugin-by-looking-at-examples" title="Permalink to this headline">¶</a></h2>
<p>If you want to write a plugin, there are many real-life examples
you can copy from:</p>
<ul class="simple">
<li>a custom collection example plugin: <a class="reference internal" href="example/nonpython.html#yaml-plugin"><em>A basic example for specifying tests in Yaml files</em></a></li>
<li>around 20 <a class="reference internal" href="#builtin-plugins">builtin plugins</a> which provide py.test&#8217;s own functionality</li>
<li>many <a class="reference internal" href="#external-plugins">external plugins</a> providing additional features</li>
</ul>
<p>All of these plugins implement the documented <a class="reference internal" href="#well-specified-hooks">well specified hooks</a>
to extend and add functionality.</p>
</div>
<div class="section" id="making-your-plugin-installable-by-others">
<span id="setuptools-entry-points"></span><h2>Making your plugin installable by others<a class="headerlink" href="#making-your-plugin-installable-by-others" title="Permalink to this headline">¶</a></h2>
<p>If you want to make your plugin externally available, you
may define a so-called entry point for your distribution so
that <tt class="docutils literal"><span class="pre">py.test</span></tt> finds your plugin module.  Entry points are
a feature that is provided by <a class="reference external" href="http://pypi.python.org/pypi/setuptools">setuptools</a> or <a class="reference external" href="http://pypi.python.org/pypi/distribute">Distribute</a>.
py.test looks up the <tt class="docutils literal"><span class="pre">pytest11</span></tt> entrypoint to discover its
plugins and you can thus make your plugin available by definig
it in your setuptools/distribute-based setup-invocation:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># sample ./setup.py file</span>
<span class="kn">from</span> <span class="nn">setuptools</span> <span class="kn">import</span> <span class="n">setup</span>

<span class="n">setup</span><span class="p">(</span>
    <span class="n">name</span><span class="o">=</span><span class="s">&quot;myproject&quot;</span><span class="p">,</span>
    <span class="n">packages</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;myproject&#39;</span><span class="p">]</span>

    <span class="c"># the following makes a plugin available to py.test</span>
    <span class="n">entry_points</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s">&#39;pytest11&#39;</span><span class="p">:</span> <span class="p">[</span>
            <span class="s">&#39;name_of_plugin = myproject.pluginmodule&#39;</span><span class="p">,</span>
        <span class="p">]</span>
    <span class="p">},</span>
<span class="p">)</span>
</pre></div>
</div>
<p>If a package is installed this way, py.test will load
<tt class="docutils literal"><span class="pre">myproject.pluginmodule</span></tt> as a plugin which can define
<a class="reference internal" href="#well-specified-hooks">well specified hooks</a>.</p>
</div>
<div class="section" id="plugin-discovery-order-at-tool-startup">
<span id="pluginorder"></span><h2>Plugin discovery order at tool startup<a class="headerlink" href="#plugin-discovery-order-at-tool-startup" title="Permalink to this headline">¶</a></h2>
<p>py.test loads plugin modules at tool startup in the following way:</p>
<ul class="simple">
<li>by loading all builtin plugins</li>
<li>by loading all plugins registered through <a class="reference internal" href="#setuptools-entry-points">setuptools entry points</a>.</li>
<li>by pre-scanning the command line for the <tt class="docutils literal"><span class="pre">-p</span> <span class="pre">name</span></tt> option
and loading the specified plugin before actual command line parsing.</li>
<li>by loading all <tt class="file docutils literal"><span class="pre">conftest.py</span></tt> files as inferred by the command line
invocation (test files and all of its <em>parent</em> directories).
Note that <tt class="docutils literal"><span class="pre">conftest.py</span></tt> files from <em>sub</em> directories are by default
not loaded at tool startup.</li>
<li>by recursively loading all plugins specified by the
<tt class="docutils literal"><span class="pre">pytest_plugins</span></tt> variable in <tt class="docutils literal"><span class="pre">conftest.py</span></tt> files</li>
</ul>
</div>
<div class="section" id="requiring-loading-plugins-in-a-test-module-or-conftest-file">
<h2>Requiring/Loading plugins in a test module or conftest file<a class="headerlink" href="#requiring-loading-plugins-in-a-test-module-or-conftest-file" title="Permalink to this headline">¶</a></h2>
<p>You can require plugins in a test module or a conftest file like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pytest_plugins</span> <span class="o">=</span> <span class="s">&quot;name1&quot;</span><span class="p">,</span> <span class="s">&quot;name2&quot;</span><span class="p">,</span>
</pre></div>
</div>
<p>When the test module or conftest plugin is loaded the specified plugins
will be loaded as well.  You can also use dotted path like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pytest_plugins</span> <span class="o">=</span> <span class="s">&quot;myapp.testsupport.myplugin&quot;</span>
</pre></div>
</div>
<p>which will import the specified module as a py.test plugin.</p>
</div>
<div class="section" id="accessing-another-plugin-by-name">
<h2>Accessing another plugin by name<a class="headerlink" href="#accessing-another-plugin-by-name" title="Permalink to this headline">¶</a></h2>
<p>If a plugin wants to collaborate with code from
another plugin it can obtain a reference through
the plugin manager like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">plugin</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">pluginmanager</span><span class="o">.</span><span class="n">getplugin</span><span class="p">(</span><span class="s">&quot;name_of_plugin&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>If you want to look at the names of existing plugins, use
the <tt class="docutils literal"><span class="pre">--traceconfig</span></tt> option.</p>
</div>
<div class="section" id="finding-out-which-plugins-are-active">
<span id="findpluginname"></span><h2>Finding out which plugins are active<a class="headerlink" href="#finding-out-which-plugins-are-active" title="Permalink to this headline">¶</a></h2>
<p>If you want to find out which plugins are active in your
environment you can type:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">py</span><span class="o">.</span><span class="n">test</span> <span class="o">--</span><span class="n">traceconfig</span>
</pre></div>
</div>
<p>and will get an extended test header which shows activated plugins
and their names. It will also print local plugins aka
<a class="reference internal" href="#conftest"><em>conftest.py</em></a> files when they are loaded.</p>
</div>
<div class="section" id="deactivating-unregistering-a-plugin-by-name">
<span id="cmdunregister"></span><h2>Deactivating / unregistering a plugin by name<a class="headerlink" href="#deactivating-unregistering-a-plugin-by-name" title="Permalink to this headline">¶</a></h2>
<p>You can prevent plugins from loading or unregister them:</p>
<div class="highlight-python"><pre>py.test -p no:NAME</pre>
</div>
<p>This means that any subsequent try to activate/load the named
plugin will it already existing.  See <a class="reference internal" href="#findpluginname"><em>Finding out which plugins are active</em></a> for
how to obtain the name of a plugin.</p>
</div>
</div>
<div class="section" id="py-test-default-plugin-reference">
<span id="builtin-plugins"></span><h1>py.test default plugin reference<a class="headerlink" href="#py-test-default-plugin-reference" title="Permalink to this headline">¶</a></h1>
<p>You can find the source code for the following plugins
in the <a class="reference external" href="http://bitbucket.org/hpk42/pytest/">pytest repository</a>.</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.assertion</span></tt></td>
<td>support for presenting detailed information in failing assertions.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.capture</span></tt></td>
<td>per-test stdout/stderr capturing mechanisms, <tt class="docutils literal"><span class="pre">capsys</span></tt> and <tt class="docutils literal"><span class="pre">capfd</span></tt> function arguments.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.config</span></tt></td>
<td>command line options, ini-file and conftest.py processing.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.doctest</span></tt></td>
<td>discover and run doctests in modules and test files.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.genscript</span></tt></td>
<td>generate a single-file self-contained version of py.test</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.helpconfig</span></tt></td>
<td>version info, help messages, tracing configuration.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.junitxml</span></tt></td>
<td>report test results in JUnit-XML format, for use with Hudson and build integration servers.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.mark</span></tt></td>
<td>generic mechanism for marking and selecting python functions.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.monkeypatch</span></tt></td>
<td>monkeypatching and mocking functionality.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.nose</span></tt></td>
<td>run test suites written for nose.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.pastebin</span></tt></td>
<td>submit failure or test session information to a pastebin service.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.pdb</span></tt></td>
<td>interactive debugging with PDB, the Python Debugger.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.pytester</span></tt></td>
<td>(disabled by default) support for testing py.test and py.test plugins.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.python</span></tt></td>
<td>Python test discovery, setup and run of test functions.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.recwarn</span></tt></td>
<td>recording warnings during test function execution.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.resultlog</span></tt></td>
<td>log machine-parseable test session result information in a plain</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.runner</span></tt></td>
<td>basic collect and runtest protocol implementations</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.main</span></tt></td>
<td>core implementation of testing process: init, session, runtest loop.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.skipping</span></tt></td>
<td>support for skip/xfail functions and markers.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.terminal</span></tt></td>
<td>terminal reporting of the full testing process.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.tmpdir</span></tt></td>
<td>support for providing temporary directories to test functions.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.unittest</span></tt></td>
<td>discovery and running of std-library &#8220;unittest&#8221; style tests.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="py-test-hook-reference">
<span id="well-specified-hooks"></span><h1>py.test hook reference<a class="headerlink" href="#py-test-hook-reference" title="Permalink to this headline">¶</a></h1>
<div class="section" id="hook-specification-and-validation">
<h2>Hook specification and validation<a class="headerlink" href="#hook-specification-and-validation" title="Permalink to this headline">¶</a></h2>
<p>py.test calls hook functions to implement initialization, running,
test execution and reporting.  When py.test loads a plugin it validates
that each hook function conforms to its respective hook specification.
Each hook function name and its argument names need to match a hook
specification.  However, a hook function may accept <em>fewer</em> parameters
by simply not specifying them.  If you mistype argument names or the
hook name itself you get an error showing the available arguments.</p>
</div>
<div class="section" id="initialization-command-line-and-configuration-hooks">
<h2>Initialization, command line and configuration hooks<a class="headerlink" href="#initialization-command-line-and-configuration-hooks" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="_pytest.hookspec.pytest_cmdline_preparse">
<tt class="descname">pytest_cmdline_preparse</tt><big>(</big><em>config</em>, <em>args</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_cmdline_preparse"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_cmdline_preparse" title="Permalink to this definition">¶</a></dt>
<dd><p>modify command line arguments before option parsing.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_cmdline_parse">
<tt class="descname">pytest_cmdline_parse</tt><big>(</big><em>pluginmanager</em>, <em>args</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_cmdline_parse"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_cmdline_parse" title="Permalink to this definition">¶</a></dt>
<dd><p>return initialized config object, parsing the specified args.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_namespace">
<tt class="descname">pytest_namespace</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_namespace"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_namespace" title="Permalink to this definition">¶</a></dt>
<dd><p>return dict of name-&gt;object to be made globally available in
the py.test/pytest namespace.  This hook is called before command
line options are parsed.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_addoption">
<tt class="descname">pytest_addoption</tt><big>(</big><em>parser</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_addoption"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_addoption" title="Permalink to this definition">¶</a></dt>
<dd><p>register optparse-style options and ini-style config values.</p>
<p>This function must be implemented in a <a class="reference internal" href="#pluginorder"><em>plugin</em></a> and is
called once at the beginning of a test 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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>parser</strong> &#8211; To add command line options, call
<a class="reference internal" href="#_pytest.config.Parser.addoption" title="_pytest.config.Parser.addoption"><tt class="xref py py-func docutils literal"><span class="pre">parser.addoption(...)</span></tt></a>.
To add ini-file values call <a class="reference internal" href="#_pytest.config.Parser.addini" title="_pytest.config.Parser.addini"><tt class="xref py py-func docutils literal"><span class="pre">parser.addini(...)</span></tt></a>.</td>
</tr>
</tbody>
</table>
<p>Options can later be accessed through the
<a class="reference internal" href="#_pytest.config.Config" title="_pytest.config.Config"><tt class="xref py py-class docutils literal"><span class="pre">config</span></tt></a> object, respectively:</p>
<ul class="simple">
<li><a class="reference internal" href="#_pytest.config.Config.getoption" title="_pytest.config.Config.getoption"><tt class="xref py py-func docutils literal"><span class="pre">config.getoption(name)</span></tt></a> to
retrieve the value of a command line option.</li>
<li><a class="reference internal" href="#_pytest.config.Config.getini" title="_pytest.config.Config.getini"><tt class="xref py py-func docutils literal"><span class="pre">config.getini(name)</span></tt></a> to retrieve
a value read from an ini-style file.</li>
</ul>
<p>The config object is passed around on many internal objects via the <tt class="docutils literal"><span class="pre">.config</span></tt>
attribute or can be retrieved as the <tt class="docutils literal"><span class="pre">pytestconfig</span></tt> fixture or accessed
via (deprecated) <tt class="docutils literal"><span class="pre">pytest.config</span></tt>.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_cmdline_main">
<tt class="descname">pytest_cmdline_main</tt><big>(</big><em>config</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_cmdline_main"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_cmdline_main" title="Permalink to this definition">¶</a></dt>
<dd><p>called for performing the main command line action. The default
implementation will invoke the configure hooks and runtest_mainloop.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_configure">
<tt class="descname">pytest_configure</tt><big>(</big><em>config</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_configure"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_configure" title="Permalink to this definition">¶</a></dt>
<dd><p>called after command line options have been parsed
and all plugins and initial conftest files been loaded.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_unconfigure">
<tt class="descname">pytest_unconfigure</tt><big>(</big><em>config</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_unconfigure"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_unconfigure" title="Permalink to this definition">¶</a></dt>
<dd><p>called before test process is exited.</p>
</dd></dl>

</div>
<div class="section" id="generic-runtest-hooks">
<h2>Generic &#8220;runtest&#8221; hooks<a class="headerlink" href="#generic-runtest-hooks" title="Permalink to this headline">¶</a></h2>
<p>All all runtest related hooks receive a <tt class="xref py py-class docutils literal"><span class="pre">pytest.Item</span></tt> object.</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_protocol">
<tt class="descname">pytest_runtest_protocol</tt><big>(</big><em>item</em>, <em>nextitem</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_protocol"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_protocol" title="Permalink to this definition">¶</a></dt>
<dd><p>implements the runtest_setup/call/teardown protocol for
the given test item, including capturing exceptions and calling
reporting hooks.</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>item</strong> &#8211; test item for which the runtest protocol is performed.</li>
<li><strong>nexitem</strong> &#8211; the scheduled-to-be-next test item (or None if this
is the end my friend).  This argument is passed on to
<a class="reference internal" href="#_pytest.hookspec.pytest_runtest_teardown" title="_pytest.hookspec.pytest_runtest_teardown"><tt class="xref py py-func docutils literal"><span class="pre">pytest_runtest_teardown()</span></tt></a>.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return boolean:</th><td class="field-body"><p class="first last">True if no further hook implementations should be invoked.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_setup">
<tt class="descname">pytest_runtest_setup</tt><big>(</big><em>item</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_setup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_setup" title="Permalink to this definition">¶</a></dt>
<dd><p>called before <tt class="docutils literal"><span class="pre">pytest_runtest_call(item)</span></tt>.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_call">
<tt class="descname">pytest_runtest_call</tt><big>(</big><em>item</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_call"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_call" title="Permalink to this definition">¶</a></dt>
<dd><p>called to execute the test <tt class="docutils literal"><span class="pre">item</span></tt>.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_teardown">
<tt class="descname">pytest_runtest_teardown</tt><big>(</big><em>item</em>, <em>nextitem</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_teardown"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_teardown" title="Permalink to this definition">¶</a></dt>
<dd><p>called after <tt class="docutils literal"><span class="pre">pytest_runtest_call</span></tt>.</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>nexitem</strong> &#8211; the scheduled-to-be-next test item (None if no further
test item is scheduled).  This argument can be used to
perform exact teardowns, i.e. calling just enough finalizers
so that nextitem only needs to call setup-functions.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_makereport">
<tt class="descname">pytest_runtest_makereport</tt><big>(</big><em>item</em>, <em>call</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_makereport"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_makereport" title="Permalink to this definition">¶</a></dt>
<dd><p>return a <a class="reference internal" href="#_pytest.runner.TestReport" title="_pytest.runner.TestReport"><tt class="xref py py-class docutils literal"><span class="pre">_pytest.runner.TestReport</span></tt></a> object
for the given <tt class="xref py py-class docutils literal"><span class="pre">pytest.Item</span></tt> and
<a class="reference internal" href="#_pytest.runner.CallInfo" title="_pytest.runner.CallInfo"><tt class="xref py py-class docutils literal"><span class="pre">_pytest.runner.CallInfo</span></tt></a>.</p>
</dd></dl>

<p>For deeper understanding you may look at the default implementation of
these hooks in <tt class="xref py py-mod docutils literal"><span class="pre">_pytest.runner</span></tt> and maybe also
in <tt class="xref py py-mod docutils literal"><span class="pre">_pytest.pdb</span></tt> which interacts with <tt class="xref py py-mod docutils literal"><span class="pre">_pytest.capture</span></tt>
and its input/output capturing in order to immediately drop
into interactive debugging when a test failure occurs.</p>
<p>The <tt class="xref py py-mod docutils literal"><span class="pre">_pytest.terminal</span></tt> reported specifically uses
the reporting hook to print information about a test run.</p>
</div>
<div class="section" id="collection-hooks">
<h2>Collection hooks<a class="headerlink" href="#collection-hooks" title="Permalink to this headline">¶</a></h2>
<p>py.test calls the following hooks for collecting files and directories:</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_ignore_collect">
<tt class="descname">pytest_ignore_collect</tt><big>(</big><em>path</em>, <em>config</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_ignore_collect"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_ignore_collect" title="Permalink to this definition">¶</a></dt>
<dd><p>return True to prevent considering this path for collection.
This hook is consulted for all files and directories prior to calling
more specific hooks.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_collect_directory">
<tt class="descname">pytest_collect_directory</tt><big>(</big><em>path</em>, <em>parent</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_collect_directory"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_collect_directory" title="Permalink to this definition">¶</a></dt>
<dd><p>called before traversing a directory for collection files.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_collect_file">
<tt class="descname">pytest_collect_file</tt><big>(</big><em>path</em>, <em>parent</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_collect_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_collect_file" title="Permalink to this definition">¶</a></dt>
<dd><p>return collection Node or None for the given path. Any new node
needs to have the specified <tt class="docutils literal"><span class="pre">parent</span></tt> as a parent.</p>
</dd></dl>

<p>For influencing the collection of objects in Python modules
you can use the following hook:</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_pycollect_makeitem">
<tt class="descname">pytest_pycollect_makeitem</tt><big>(</big><em>collector</em>, <em>name</em>, <em>obj</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_pycollect_makeitem"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_pycollect_makeitem" title="Permalink to this definition">¶</a></dt>
<dd><p>return custom item/collector for a python object in a module, or None.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_generate_tests">
<tt class="descname">pytest_generate_tests</tt><big>(</big><em>metafunc</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_generate_tests"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_generate_tests" title="Permalink to this definition">¶</a></dt>
<dd><p>generate (multiple) parametrized calls to a test function.</p>
</dd></dl>

</div>
<div class="section" id="reporting-hooks">
<h2>Reporting hooks<a class="headerlink" href="#reporting-hooks" title="Permalink to this headline">¶</a></h2>
<p>Session related reporting hooks:</p>
<p>And here is the central hook for reporting about
test execution:</p>
</div>
</div>
<div class="section" id="reference-of-objects-involved-in-hooks">
<h1>Reference of objects involved in hooks<a class="headerlink" href="#reference-of-objects-involved-in-hooks" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="_pytest.config.Config">
<em class="property">class </em><tt class="descname">Config</tt><a class="reference internal" href="_modules/_pytest/config.html#Config"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Config" title="Permalink to this definition">¶</a></dt>
<dd><p>access to configuration values, pluginmanager and plugin hooks.</p>
<dl class="attribute">
<dt id="_pytest.config.Config.option">
<tt class="descname">option</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.config.Config.option" title="Permalink to this definition">¶</a></dt>
<dd><p>access to command line option as attributes.
(deprecated), use <a class="reference internal" href="#_pytest.config.Config.getoption" title="_pytest.config.Config.getoption"><tt class="xref py py-func docutils literal"><span class="pre">getoption()</span></tt></a> instead</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.config.Config.pluginmanager">
<tt class="descname">pluginmanager</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.config.Config.pluginmanager" title="Permalink to this definition">¶</a></dt>
<dd><p>a pluginmanager instance</p>
</dd></dl>

<dl class="classmethod">
<dt id="_pytest.config.Config.fromdictargs">
<em class="property">classmethod </em><tt class="descname">fromdictargs</tt><big>(</big><em>option_dict</em>, <em>args</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.fromdictargs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Config.fromdictargs" title="Permalink to this definition">¶</a></dt>
<dd><p>constructor useable for subprocesses.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Config.addinivalue_line">
<tt class="descname">addinivalue_line</tt><big>(</big><em>name</em>, <em>line</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.addinivalue_line"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Config.addinivalue_line" title="Permalink to this definition">¶</a></dt>
<dd><p>add a line to an ini-file option. The option must have been
declared but might not yet be set in which case the line becomes the
the first line in its value.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Config.getini">
<tt class="descname">getini</tt><big>(</big><em>name</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.getini"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Config.getini" title="Permalink to this definition">¶</a></dt>
<dd><p>return configuration value from an <a class="reference internal" href="customize.html#inifiles"><em>ini file</em></a>. If the
specified name hasn&#8217;t been registered through a prior
<tt class="xref py py-func docutils literal"><span class="pre">parser.addini</span></tt>
call (usually from a plugin), a ValueError is raised.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Config.getoption">
<tt class="descname">getoption</tt><big>(</big><em>name</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.getoption"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Config.getoption" title="Permalink to this definition">¶</a></dt>
<dd><p>return command line option value.</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>name</strong> &#8211; name of the option.  You may also specify
the literal <tt class="docutils literal"><span class="pre">--OPT</span></tt> option instead of the &#8220;dest&#8221; option name.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Config.getvalue">
<tt class="descname">getvalue</tt><big>(</big><em>name</em>, <em>path=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.getvalue"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Config.getvalue" title="Permalink to this definition">¶</a></dt>
<dd><p>return command line option value.</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>name</strong> &#8211; name of the command line option</td>
</tr>
</tbody>
</table>
<p>(deprecated) if we can&#8217;t find the option also lookup
the name in a matching conftest file.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Config.getvalueorskip">
<tt class="descname">getvalueorskip</tt><big>(</big><em>name</em>, <em>path=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.getvalueorskip"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Config.getvalueorskip" title="Permalink to this definition">¶</a></dt>
<dd><p>(deprecated) return getvalue(name) or call
py.test.skip if no value exists.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="_pytest.config.Parser">
<em class="property">class </em><tt class="descname">Parser</tt><a class="reference internal" href="_modules/_pytest/config.html#Parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Parser" title="Permalink to this definition">¶</a></dt>
<dd><p>Parser for command line arguments and ini-file values.</p>
<dl class="method">
<dt id="_pytest.config.Parser.getgroup">
<tt class="descname">getgroup</tt><big>(</big><em>name</em>, <em>description=''</em>, <em>after=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Parser.getgroup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Parser.getgroup" title="Permalink to this definition">¶</a></dt>
<dd><p>get (or create) a named option Group.</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">Name :</th><td class="field-body">name of the option group.</td>
</tr>
<tr class="field-even field"><th class="field-name">Description :</th><td class="field-body">long description for &#8211;help output.</td>
</tr>
<tr class="field-odd field"><th class="field-name">After :</th><td class="field-body">name of other group, used for ordering &#8211;help output.</td>
</tr>
</tbody>
</table>
<p>The returned group object has an <tt class="docutils literal"><span class="pre">addoption</span></tt> method with the same
signature as <a class="reference internal" href="#_pytest.config.Parser.addoption" title="_pytest.config.Parser.addoption"><tt class="xref py py-func docutils literal"><span class="pre">parser.addoption</span></tt></a> but will be shown in the
respective group in the output of <tt class="docutils literal"><span class="pre">pytest.</span> <span class="pre">--help</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Parser.addoption">
<tt class="descname">addoption</tt><big>(</big><em>*opts</em>, <em>**attrs</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Parser.addoption"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Parser.addoption" title="Permalink to this definition">¶</a></dt>
<dd><p>register a command line option.</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">Opts :</th><td class="field-body">option names, can be short or long options.</td>
</tr>
<tr class="field-even field"><th class="field-name">Attrs :</th><td class="field-body">same attributes which the <tt class="docutils literal"><span class="pre">add_option()</span></tt> function of the
<a class="reference external" href="http://docs.python.org/library/optparse.html#module-optparse">optparse library</a>
accepts.</td>
</tr>
</tbody>
</table>
<p>After command line parsing options are available on the pytest config
object via <tt class="docutils literal"><span class="pre">config.option.NAME</span></tt> where <tt class="docutils literal"><span class="pre">NAME</span></tt> is usually set
by passing a <tt class="docutils literal"><span class="pre">dest</span></tt> attribute, for example
<tt class="docutils literal"><span class="pre">addoption(&quot;--long&quot;,</span> <span class="pre">dest=&quot;NAME&quot;,</span> <span class="pre">...)</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Parser.addini">
<tt class="descname">addini</tt><big>(</big><em>name</em>, <em>help</em>, <em>type=None</em>, <em>default=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Parser.addini"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Parser.addini" title="Permalink to this definition">¶</a></dt>
<dd><p>register an ini-file option.</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">Name :</th><td class="field-body">name of the ini-variable</td>
</tr>
<tr class="field-even field"><th class="field-name">Type :</th><td class="field-body">type of the variable, can be <tt class="docutils literal"><span class="pre">pathlist</span></tt>, <tt class="docutils literal"><span class="pre">args</span></tt> or <tt class="docutils literal"><span class="pre">linelist</span></tt>.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Default :</th><td class="field-body">default value if no ini-file option exists but is queried.</td>
</tr>
</tbody>
</table>
<p>The value of ini-variables can be retrieved via a call to
<a class="reference internal" href="#_pytest.config.Config.getini" title="_pytest.config.Config.getini"><tt class="xref py py-func docutils literal"><span class="pre">config.getini(name)</span></tt></a>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="_pytest.main.Node">
<em class="property">class </em><tt class="descname">Node</tt><a class="reference internal" href="_modules/_pytest/main.html#Node"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Node" title="Permalink to this definition">¶</a></dt>
<dd><p>base class for Collector and Item the test collection tree.
Collector subclasses have children, Items are terminal nodes.</p>
<dl class="attribute">
<dt id="_pytest.main.Node.name">
<tt class="descname">name</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.name" title="Permalink to this definition">¶</a></dt>
<dd><p>a unique name within the scope of the parent node</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.parent">
<tt class="descname">parent</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.parent" title="Permalink to this definition">¶</a></dt>
<dd><p>the parent collector node.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.config">
<tt class="descname">config</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.config" title="Permalink to this definition">¶</a></dt>
<dd><p>the pytest config object</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.session">
<tt class="descname">session</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.session" title="Permalink to this definition">¶</a></dt>
<dd><p>the session this node is part of</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.fspath">
<tt class="descname">fspath</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.fspath" title="Permalink to this definition">¶</a></dt>
<dd><p>filesystem path where this node was collected from (can be None)</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.keywords">
<tt class="descname">keywords</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.keywords" title="Permalink to this definition">¶</a></dt>
<dd><p>keywords/markers collected from all scopes</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.ihook">
<tt class="descname">ihook</tt><a class="reference internal" href="_modules/_pytest/main.html#Node.ihook"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Node.ihook" title="Permalink to this definition">¶</a></dt>
<dd><p>fspath sensitive hook proxy used to call pytest hooks</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.nodeid">
<tt class="descname">nodeid</tt><a class="reference internal" href="_modules/_pytest/main.html#Node.nodeid"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Node.nodeid" title="Permalink to this definition">¶</a></dt>
<dd><p>a ::-separated string denoting its collection tree address.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.main.Node.listchain">
<tt class="descname">listchain</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Node.listchain"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Node.listchain" title="Permalink to this definition">¶</a></dt>
<dd><p>return list of all parent collectors up to self,
starting from root of collection tree.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="_pytest.main.Collector">
<em class="property">class </em><tt class="descname">Collector</tt><a class="reference internal" href="_modules/_pytest/main.html#Collector"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Collector" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#_pytest.main.Node" title="_pytest.main.Node"><tt class="xref py py-class docutils literal"><span class="pre">_pytest.main.Node</span></tt></a></p>
<p>Collector instances create children through collect()
and thus iteratively build a tree.</p>
<dl class="exception">
<dt id="_pytest.main.Collector.CollectError">
<em class="property">exception </em><tt class="descname">CollectError</tt><a class="reference internal" href="_modules/_pytest/main.html#Collector.CollectError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Collector.CollectError" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">exceptions.Exception</span></tt></p>
<p>an error during collection, contains a custom message.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.main.Collector.collect">
<tt class="descclassname">Collector.</tt><tt class="descname">collect</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Collector.collect"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Collector.collect" title="Permalink to this definition">¶</a></dt>
<dd><p>returns a list of children (items and collectors)
for this collection node.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.main.Collector.repr_failure">
<tt class="descclassname">Collector.</tt><tt class="descname">repr_failure</tt><big>(</big><em>excinfo</em><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Collector.repr_failure"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Collector.repr_failure" title="Permalink to this definition">¶</a></dt>
<dd><p>represent a collection failure.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="_pytest.main.Item">
<em class="property">class </em><tt class="descname">Item</tt><a class="reference internal" href="_modules/_pytest/main.html#Item"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Item" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#_pytest.main.Node" title="_pytest.main.Node"><tt class="xref py py-class docutils literal"><span class="pre">_pytest.main.Node</span></tt></a></p>
<p>a basic test invocation item. Note that for a single function
there might be multiple test invocation items.</p>
</dd></dl>

<dl class="class">
<dt id="_pytest.python.Module">
<em class="property">class </em><tt class="descname">Module</tt><a class="reference internal" href="_modules/_pytest/python.html#Module"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.Module" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">_pytest.main.File</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">_pytest.python.PyCollector</span></tt></p>
<p>Collector for test classes and functions.</p>
</dd></dl>

<dl class="class">
<dt id="_pytest.python.Class">
<em class="property">class </em><tt class="descname">Class</tt><a class="reference internal" href="_modules/_pytest/python.html#Class"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.Class" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">_pytest.python.PyCollector</span></tt></p>
<p>Collector for test methods.</p>
</dd></dl>

<dl class="class">
<dt id="_pytest.python.Function">
<em class="property">class </em><tt class="descname">Function</tt><a class="reference internal" href="_modules/_pytest/python.html#Function"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.Function" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">_pytest.python.FunctionMixin</span></tt>, <a class="reference internal" href="#_pytest.main.Item" title="_pytest.main.Item"><tt class="xref py py-class docutils literal"><span class="pre">_pytest.main.Item</span></tt></a>, <tt class="xref py py-class docutils literal"><span class="pre">_pytest.python.FuncargnamesCompatAttr</span></tt></p>
<p>a Function Item is responsible for setting up and executing a
Python test function.</p>
<dl class="attribute">
<dt id="_pytest.python.Function.function">
<tt class="descname">function</tt><a class="reference internal" href="_modules/_pytest/python.html#Function.function"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.Function.function" title="Permalink to this definition">¶</a></dt>
<dd><p>underlying python &#8216;function&#8217; object</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.python.Function.runtest">
<tt class="descname">runtest</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/_pytest/python.html#Function.runtest"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.python.Function.runtest" title="Permalink to this definition">¶</a></dt>
<dd><p>execute the underlying test function.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="_pytest.runner.CallInfo">
<em class="property">class </em><tt class="descname">CallInfo</tt><a class="reference internal" href="_modules/_pytest/runner.html#CallInfo"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.runner.CallInfo" title="Permalink to this definition">¶</a></dt>
<dd><p>Result/Exception info a function invocation.</p>
<dl class="attribute">
<dt id="_pytest.runner.CallInfo.when">
<tt class="descname">when</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.CallInfo.when" title="Permalink to this definition">¶</a></dt>
<dd><p>context of invocation: one of &#8220;setup&#8221;, &#8220;call&#8221;,
&#8220;teardown&#8221;, &#8220;memocollect&#8221;</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.CallInfo.excinfo">
<tt class="descname">excinfo</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.CallInfo.excinfo" title="Permalink to this definition">¶</a></dt>
<dd><p>None or ExceptionInfo object.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="_pytest.runner.TestReport">
<em class="property">class </em><tt class="descname">TestReport</tt><a class="reference internal" href="_modules/_pytest/runner.html#TestReport"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.runner.TestReport" title="Permalink to this definition">¶</a></dt>
<dd><p>Basic test report object (also used for setup and teardown calls if
they fail).</p>
<dl class="attribute">
<dt id="_pytest.runner.TestReport.nodeid">
<tt class="descname">nodeid</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.nodeid" title="Permalink to this definition">¶</a></dt>
<dd><p>normalized collection node id</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.location">
<tt class="descname">location</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.location" title="Permalink to this definition">¶</a></dt>
<dd><p>a (filesystempath, lineno, domaininfo) tuple indicating the
actual location of a test item - it might be different from the
collected one e.g. if a method is inherited from a different module.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.keywords">
<tt class="descname">keywords</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.keywords" title="Permalink to this definition">¶</a></dt>
<dd><p>a name -&gt; value dictionary containing all keywords and
markers associated with a test invocation.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.outcome">
<tt class="descname">outcome</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.outcome" title="Permalink to this definition">¶</a></dt>
<dd><p>test outcome, always one of &#8220;passed&#8221;, &#8220;failed&#8221;, &#8220;skipped&#8221;.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.longrepr">
<tt class="descname">longrepr</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.longrepr" title="Permalink to this definition">¶</a></dt>
<dd><p>None or a failure representation.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.when">
<tt class="descname">when</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.when" title="Permalink to this definition">¶</a></dt>
<dd><p>one of &#8216;setup&#8217;, &#8216;call&#8217;, &#8216;teardown&#8217; to indicate runtest phase.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.sections">
<tt class="descname">sections</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.sections" title="Permalink to this definition">¶</a></dt>
<dd><p>list of (secname, data) extra information which needs to
marshallable</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.duration">
<tt class="descname">duration</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.duration" title="Permalink to this definition">¶</a></dt>
<dd><p>time it took to run just the test</p>
</dd></dl>

</dd></dl>

</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="example/index.html" title="Usages and Examples"
             >next</a></li>
        <li class="right" >
          <a href="doctest.html" title="Doctest integration for modules and test files"
             >previous</a> |</li>
        <li><a href="contents.html">pytest-2.3.4.1</a> &raquo;</li>
 
<g:plusone></g:plusone>

      </ul>
    </div>

    <div class="footer">
        &copy; Copyright 2012, holger krekel.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </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>