Current File : //usr/share/doc/pytest-2.7.0/html/en/plugins.html
<!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/flasky.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '2.7.0',
        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="shortcut icon" href="_static/pytest1favi.ico"/>
    <link rel="top" title="None" href="index.html" />
    <link rel="next" title="List of Third-Party Plugins" href="plugins_index/index.html" />
    <link rel="prev" title="Doctest integration for modules and test files" href="doctest.html" />
   
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">

  </head>
  <body>
  
  

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="plugins_index/index.html" title="List of Third-Party Plugins"
             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.7.0</a> &raquo;</li> 
      </ul>
    </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><tt class="docutils literal"><span class="pre">pytest</span></tt> 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 pytest&#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_sub.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, <tt class="docutils literal"><span class="pre">pytest</span></tt> automatically finds and integrates it,
there is no need to activate it.  We have a <a class="reference internal" href="plugins_index/index.html"><em>page listing
all 3rd party plugins and their status against the latest py.test version</em></a> and here is a little annotated list
for some popular 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-cov">pytest-cov</a>:
coverage reporting, compatible with distributed testing</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-instafail">pytest-instafail</a>:
to report failures while the test run is happening.</li>
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-bdd">pytest-bdd</a> and
<a class="reference external" href="http://pypi.python.org/pypi/pytest-konira">pytest-konira</a>
to write tests using behaviour-driven testing.</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-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>To see a complete list of all plugins with their latest testing
status against different py.test and Python versions, please visit
<a class="reference external" href="http://plugincompat.herokuapp.com/">plugincompat</a>.</p>
<p>You may also 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 pytest&#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>
<p>You can also <em class="xref std std-ref">contribute your plugin to pytest-dev</em>
once it has some happy users other than yourself.</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">pytest</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>. pytest 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 defining
it in your setuptools-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 pytest</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, <tt class="docutils literal"><span class="pre">pytest</span></tt> 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><tt class="docutils literal"><span class="pre">pytest</span></tt> loads plugin modules at tool startup in the following way:</p>
<ul>
<li><p class="first">by loading all builtin plugins</p>
</li>
<li><p class="first">by loading all plugins registered through <a class="reference internal" href="#setuptools-entry-points">setuptools entry points</a>.</p>
</li>
<li><p class="first">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.</p>
</li>
<li><p class="first">by loading all <tt class="file docutils literal"><span class="pre">conftest.py</span></tt> files as inferred by the command line
invocation:</p>
<ul class="simple">
<li>if no test paths are specified use current dir as a test path</li>
<li>if exists, load <tt class="docutils literal"><span class="pre">conftest.py</span></tt> and <tt class="docutils literal"><span class="pre">test*/conftest.py</span></tt> relative
to the directory part of the first test path.</li>
</ul>
<p>Note that pytest does not find <tt class="docutils literal"><span class="pre">conftest.py</span></tt> files in deeper nested
sub directories at tool startup.  It is usually a good idea to keep
your conftest.py file in the top level test or project root directory.</p>
</li>
<li><p class="first">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</p>
</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 <tt class="docutils literal"><span class="pre">pytest</span></tt> 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="pytest-default-plugin-reference">
<span id="builtin-plugins"></span><h1>pytest default plugin reference<a class="headerlink" href="#pytest-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/pytest-dev/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 mechanism.</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 pytest</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 pytest and pytest 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="pytest-hook-reference">
<span id="well-specified-hooks"></span><h1>pytest hook reference<a class="headerlink" href="#pytest-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><tt class="docutils literal"><span class="pre">pytest</span></tt> calls hook functions to implement initialization, running,
test execution and reporting.  When <tt class="docutils literal"><span class="pre">pytest</span></tt> 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_load_initial_conftests">
<tt class="descname">pytest_load_initial_conftests</tt><big>(</big><em>args</em>, <em>early_config</em>, <em>parser</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_load_initial_conftests"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_load_initial_conftests" title="Permalink to this definition">¶</a></dt>
<dd><p>implements the loading of initial conftest files ahead
of command line option parsing.</p>
</dd></dl>

<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>(deprecated) 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 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 argparse-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 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>nextitem</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>nextitem</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><tt class="docutils literal"><span class="pre">pytest</span></tt> 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>

<p>After collection is complete, you can modify the order of
items, delete or otherwise amend the test items:</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_collection_modifyitems">
<tt class="descname">pytest_collection_modifyitems</tt><big>(</big><em>session</em>, <em>config</em>, <em>items</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_collection_modifyitems"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_collection_modifyitems" title="Permalink to this definition">¶</a></dt>
<dd><p>called after collection has been performed, may filter or re-order
the items in-place.</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>
<dl class="function">
<dt id="_pytest.hookspec.pytest_collectstart">
<tt class="descname">pytest_collectstart</tt><big>(</big><em>collector</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_collectstart"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_collectstart" title="Permalink to this definition">¶</a></dt>
<dd><p>collector starts collecting.</p>
</dd></dl>

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

<dl class="function">
<dt id="_pytest.hookspec.pytest_collectreport">
<tt class="descname">pytest_collectreport</tt><big>(</big><em>report</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_collectreport"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_collectreport" title="Permalink to this definition">¶</a></dt>
<dd><p>collector finished collecting.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_deselected">
<tt class="descname">pytest_deselected</tt><big>(</big><em>items</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_deselected"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_deselected" title="Permalink to this definition">¶</a></dt>
<dd><p>called for test items deselected by keyword.</p>
</dd></dl>

<p>And here is the central hook for reporting about
test execution:</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_logreport">
<tt class="descname">pytest_runtest_logreport</tt><big>(</big><em>report</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_logreport"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_logreport" title="Permalink to this definition">¶</a></dt>
<dd><p>process a test setup/call/teardown report relating to
the respective phase of executing a test.</p>
</dd></dl>

</div>
<div class="section" id="debugging-interaction-hooks">
<h2>Debugging/Interaction hooks<a class="headerlink" href="#debugging-interaction-hooks" title="Permalink to this headline">¶</a></h2>
<p>There are few hooks which can be used for special
reporting or interaction with exceptions:</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_internalerror">
<tt class="descname">pytest_internalerror</tt><big>(</big><em>excrepr</em>, <em>excinfo</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_internalerror"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_internalerror" title="Permalink to this definition">¶</a></dt>
<dd><p>called for internal errors.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_keyboard_interrupt">
<tt class="descname">pytest_keyboard_interrupt</tt><big>(</big><em>excinfo</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_keyboard_interrupt"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_keyboard_interrupt" title="Permalink to this definition">¶</a></dt>
<dd><p>called for keyboard interrupt.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_exception_interact">
<tt class="descname">pytest_exception_interact</tt><big>(</big><em>node</em>, <em>call</em>, <em>report</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_exception_interact"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_exception_interact" title="Permalink to this definition">¶</a></dt>
<dd><p>(experimental, new in 2.4) called when
an exception was raised which can potentially be
interactively handled.</p>
<p>This hook is only called if an exception was raised
that is not an internal exception like &#8220;skip.Exception&#8221;.</p>
</dd></dl>

</div>
<div class="section" id="declaring-new-hooks">
<h2>Declaring new hooks<a class="headerlink" href="#declaring-new-hooks" title="Permalink to this headline">¶</a></h2>
<p>Plugins and <tt class="docutils literal"><span class="pre">conftest.py</span></tt> files may declare new hooks that can then be
implemented by other plugins in order to alter behaviour or interact with
the new plugin:</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_addhooks">
<tt class="descname">pytest_addhooks</tt><big>(</big><em>pluginmanager</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_addhooks"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_addhooks" title="Permalink to this definition">¶</a></dt>
<dd><p>called at plugin load time to allow adding new hooks via a call to
pluginmanager.registerhooks(module).</p>
</dd></dl>

<p>Hooks are usually declared as do-nothing functions that contain only
documentation describing when the hook will be called and what return values
are expected.</p>
<p>For an example, see <a class="reference external" href="https://bitbucket.org/pytest-dev/pytest-xdist/src/52082f70e7dd04b00361091b8af906c60fd6700f/xdist/newhooks.py?at=default">newhooks.py</a> from <a class="reference internal" href="xdist.html#xdist"><em>xdist: pytest distributed testing plugin</em></a>.</p>
</div>
<div class="section" id="using-hooks-from-3rd-party-plugins">
<h2>Using hooks from 3rd party plugins<a class="headerlink" href="#using-hooks-from-3rd-party-plugins" title="Permalink to this headline">¶</a></h2>
<p>Using new hooks from plugins as explained above might be a little tricky
because the standard <a class="reference internal" href="#hook-specification-and-validation">Hook specification and validation</a> mechanism:
if you depend on a plugin that is not installed,
validation will fail and the error message will not make much sense to your users.</p>
<p>One approach is to defer the hook implementation to a new plugin instead of
declaring the hook functions directly in your plugin module, for example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># contents of myplugin.py</span>

<span class="k">class</span> <span class="nc">DeferPlugin</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Simple plugin to defer pytest-xdist hook functions.&quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">pytest_testnodedown</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">node</span><span class="p">,</span> <span class="n">error</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;standard xdist hook function.</span>
<span class="sd">        &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="nf">pytest_configure</span><span class="p">(</span><span class="n">config</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">config</span><span class="o">.</span><span class="n">pluginmanager</span><span class="o">.</span><span class="n">hasplugin</span><span class="p">(</span><span class="s">&#39;xdist&#39;</span><span class="p">):</span>
        <span class="n">config</span><span class="o">.</span><span class="n">pluginmanager</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">DeferPlugin</span><span class="p">())</span>
</pre></div>
</div>
<p>This has the added benefit of allowing you to conditionally install hooks
depending on which plugins are installed.</p>
</div>
<div class="section" id="hookwrapper-executing-around-other-hooks">
<h2>hookwrapper: executing around other hooks<a class="headerlink" href="#hookwrapper-executing-around-other-hooks" title="Permalink to this headline">¶</a></h2>
<p class="versionadded">
<span class="versionmodified">New in version 2.7: </span>(experimental)</p>
<p>pytest plugins can implement hook wrappers which which wrap the execution
of other hook implementations.  A hook wrapper is a generator function
which yields exactly once. When pytest invokes hooks it first executes
hook wrappers and passes the same arguments as to the regular hooks.</p>
<p>At the yield point of the hook wrapper pytest will execute the next hook
implementations and return their result to the yield point in the form of
a <a class="reference internal" href="#_pytest.core.CallOutcome" title="_pytest.core.CallOutcome"><tt class="xref py py-class docutils literal"><span class="pre">CallOutcome</span></tt></a> instance which encapsulates a result or
exception info.  The yield point itself will thus typically not raise
exceptions (unless there are bugs).</p>
<p>Here is an example definition of a hook wrapper:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">pytest</span>

<span class="nd">@pytest.mark.hookwrapper</span>
<span class="k">def</span> <span class="nf">pytest_pyfunc_call</span><span class="p">(</span><span class="n">pyfuncitem</span><span class="p">):</span>
    <span class="c"># do whatever you want before the next hook executes</span>
    <span class="n">outcome</span> <span class="o">=</span> <span class="k">yield</span>
    <span class="c"># outcome.excinfo may be None or a (cls, val, tb) tuple</span>
    <span class="n">res</span> <span class="o">=</span> <span class="n">outcome</span><span class="o">.</span><span class="n">get_result</span><span class="p">()</span>  <span class="c"># will raise if outcome was exception</span>
    <span class="c"># postprocess result</span>
</pre></div>
</div>
<p>Note that hook wrappers don&#8217;t return results themselves, they merely
perform tracing or other side effects around the actual hook implementations.
If the result of the underlying hook is a mutable object, they may modify
that result, however.</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="method">
<dt id="_pytest.config.Config.warn">
<tt class="descname">warn</tt><big>(</big><em>code</em>, <em>message</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.warn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.config.Config.warn" title="Permalink to this definition">¶</a></dt>
<dd><p>generate a warning for this test session.</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>, <em>default=&lt;NOTSET&gt;</em>, <em>skip=False</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"><ul class="first last simple">
<li><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.</li>
<li><strong>default</strong> &#8211; default value if no option of that name exists.</li>
<li><strong>skip</strong> &#8211; if True raise pytest.skip if option does not exists
or has a None value.</li>
</ul>
</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>(deprecated, use getoption())</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, use getoption(skip=True))</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/2/library/argparse.html">argparse 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.extra_keyword_matches">
<tt class="descname">extra_keyword_matches</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.extra_keyword_matches" title="Permalink to this definition">¶</a></dt>
<dd><p>allow adding of extra keywords to use for matching</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="method">
<dt id="_pytest.main.Node.warn">
<tt class="descname">warn</tt><big>(</big><em>code</em>, <em>message</em><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Node.warn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Node.warn" title="Permalink to this definition">¶</a></dt>
<dd><p>generate a warning with the given code and message for this
item.</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>

<dl class="method">
<dt id="_pytest.main.Node.add_marker">
<tt class="descname">add_marker</tt><big>(</big><em>marker</em><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Node.add_marker"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Node.add_marker" title="Permalink to this definition">¶</a></dt>
<dd><p>dynamically add a marker object to the node.</p>
<p><tt class="docutils literal"><span class="pre">marker</span></tt> can be a string or pytest.mark.* instance.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.main.Node.get_marker">
<tt class="descname">get_marker</tt><big>(</big><em>name</em><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Node.get_marker"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Node.get_marker" title="Permalink to this definition">¶</a></dt>
<dd><p>get a marker object from this node or None if
the node doesn&#8217;t have a marker with that name.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.main.Node.listextrakeywords">
<tt class="descname">listextrakeywords</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Node.listextrakeywords"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Node.listextrakeywords" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a set of all extra keywords in self and any parents.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.main.Node.addfinalizer">
<tt class="descname">addfinalizer</tt><big>(</big><em>fin</em><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Node.addfinalizer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Node.addfinalizer" title="Permalink to this definition">¶</a></dt>
<dd><p>register a function to be called when this node is finalized.</p>
<p>This method can only be called when this node is active
in a setup chain, for example during self.setup().</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.main.Node.getparent">
<tt class="descname">getparent</tt><big>(</big><em>cls</em><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Node.getparent"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.main.Node.getparent" title="Permalink to this definition">¶</a></dt>
<dd><p>get the next parent node (including ourself)
which is an instance of the given class</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>

<dl class="class">
<dt id="_pytest.core.CallOutcome">
<em class="property">class </em><tt class="descname">CallOutcome</tt><a class="reference internal" href="_modules/_pytest/core.html#CallOutcome"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#_pytest.core.CallOutcome" title="Permalink to this definition">¶</a></dt>
<dd><p>Outcome of a function call, either an exception or a proper result.
Calling the <tt class="docutils literal"><span class="pre">get_result</span></tt> method will return the result or reraise
the exception raised when the function was called.</p>
</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="contents.html">
              <img class="logo" src="_static/pytest1.png" alt="Logo"/>
            </a></p><h3><a href="contents.html">Table Of Contents</a></h3>

<ul>
  <li><a href="index.html">Home</a></li>
  <li><a href="contents.html">Contents</a></li>
  <li><a href="getting-started.html">Install</a></li>
  <li><a href="example/index.html">Examples</a></li>
  <li><a href="customize.html">Customize</a></li>
  <li><a href="contact.html">Contact</a></li>
  <li><a href="talks.html">Talks/Posts</a></li>
  <li><a href="changelog.html">Changelog</a></li>
</ul>
  <hr>
  <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="#pytest-default-plugin-reference">pytest default plugin reference</a></li>
<li><a class="reference internal" href="#pytest-hook-reference">pytest 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>
<li><a class="reference internal" href="#debugging-interaction-hooks">Debugging/Interaction hooks</a></li>
<li><a class="reference internal" href="#declaring-new-hooks">Declaring new hooks</a></li>
<li><a class="reference internal" href="#using-hooks-from-3rd-party-plugins">Using hooks from 3rd party plugins</a></li>
<li><a class="reference internal" href="#hookwrapper-executing-around-other-hooks">hookwrapper: executing around other 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>
<h3>Related Topics</h3>
<ul>
  <li><a href="contents.html">Documentation overview</a><ul>
      <li>Previous: <a href="doctest.html" title="previous chapter">Doctest integration for modules and test files</a></li>
      <li>Next: <a href="plugins_index/index.html" title="next chapter">List of Third-Party Plugins</a></li>
  </ul></li>
</ul><h3>Useful Links</h3>
<ul>
  <li><a href="index.html">The pytest Website</a></li>
  <li><a href="contributing.html">Contribution Guide</a></li>
  <li><a href="https://pypi.python.org/pypi/pytest">pytest @ PyPI</a></li>
  <li><a href="https://bitbucket.org/pytest-dev/pytest/">pytest @ Bitbucket</a></li>
  <li><a href="http://pytest.org/latest/plugins_index/index.html">3rd party plugins</a></li>
  <li><a href="https://bitbucket.org/pytest-dev/pytest/issues?status=new&status=open">Issue Tracker</a></li>
  <li><a href="http://pytest.org/latest/pytest.pdf">PDF Documentation</a>
</ul>

<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>

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

  </body>
</html>