Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 7f671eb35339cf812de52087b0d93519 > files > 239

python3-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>Basic test configuration</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="up" title="py.test reference documentation" href="apiref.html" />
    <link rel="next" title="The writing and reporting of assertions in tests" href="assert.html" />
    <link rel="prev" title="Pytest API and builtin fixtures" href="builtin.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="assert.html" title="The writing and reporting of assertions in tests"
             accesskey="N">next</a></li>
        <li class="right" >
          <a href="builtin.html" title="Pytest API and builtin fixtures"
             accesskey="P">previous</a> |</li>
        <li><a href="contents.html">pytest-2.3.4.1</a> &raquo;</li>
          <li><a href="apiref.html" accesskey="U">py.test reference documentation</a> &raquo;</li>
 
<g:plusone></g:plusone>

      </ul>
    </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Search" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>

<h3>quicklinks</h3>
<div style="text-align: left; font-size: 100%; vertical-align: middle;">
<table>
<tr>
<td>
        <a href="index.html">home</a>
</td><td>
        <a href="contents.html">TOC/contents</a>
</td></tr><tr><td>
        <a href="getting-started.html">install</a>
</td><td>
        <a href="changelog.html">changelog</a>
</td></tr><tr><td>
        <a href="example/index.html">examples</a>
</td><td>
        <a href="#">customize</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="#">Basic test configuration</a><ul>
<li><a class="reference internal" href="#command-line-options-and-configuration-file-settings">Command line options and configuration file settings</a></li>
<li><a class="reference internal" href="#how-test-configuration-is-read-from-configuration-ini-files">How test configuration is read from configuration INI-files</a></li>
<li><a class="reference internal" href="#adding-default-options">How to change command line options defaults</a></li>
<li><a class="reference internal" href="#builtin-configuration-file-options">Builtin configuration file options</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="builtin.html"
                        title="previous chapter">Pytest API and builtin fixtures</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="assert.html"
                        title="next chapter">The writing and reporting of assertions in tests</a></p>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="basic-test-configuration">
<h1>Basic test configuration<a class="headerlink" href="#basic-test-configuration" title="Permalink to this headline">¶</a></h1>
<div class="section" id="command-line-options-and-configuration-file-settings">
<h2>Command line options and configuration file settings<a class="headerlink" href="#command-line-options-and-configuration-file-settings" title="Permalink to this headline">¶</a></h2>
<p>You can get help on command line options and values in INI-style
configurations files by using the general help option:</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">h</span>   <span class="c"># prints options _and_ config file settings</span>
</pre></div>
</div>
<p>This will display command line and configuration file settings
which were registered by installed plugins.</p>
</div>
<div class="section" id="how-test-configuration-is-read-from-configuration-ini-files">
<span id="inifiles"></span><h2>How test configuration is read from configuration INI-files<a class="headerlink" href="#how-test-configuration-is-read-from-configuration-ini-files" title="Permalink to this headline">¶</a></h2>
<p>py.test searches for the first matching ini-style configuration file
in the directories of command line argument and the directories above.
It looks for file basenames in this order:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pytest</span><span class="o">.</span><span class="n">ini</span>
<span class="n">tox</span><span class="o">.</span><span class="n">ini</span>
<span class="n">setup</span><span class="o">.</span><span class="n">cfg</span>
</pre></div>
</div>
<p>Searching stops when the first <tt class="docutils literal"><span class="pre">[pytest]</span></tt> section is found in any of
these files.  There is no merging of configuration values from multiple
files.  Example:</p>
<div class="highlight-python"><pre>py.test path/to/testdir</pre>
</div>
<p>will look in the following dirs for a config file:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">testdir</span><span class="o">/</span><span class="n">pytest</span><span class="o">.</span><span class="n">ini</span>
<span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">testdir</span><span class="o">/</span><span class="n">tox</span><span class="o">.</span><span class="n">ini</span>
<span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">testdir</span><span class="o">/</span><span class="n">setup</span><span class="o">.</span><span class="n">cfg</span>
<span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">pytest</span><span class="o">.</span><span class="n">ini</span>
<span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">tox</span><span class="o">.</span><span class="n">ini</span>
<span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">setup</span><span class="o">.</span><span class="n">cfg</span>
<span class="o">...</span> <span class="c"># up until root of filesystem</span>
</pre></div>
</div>
<p>If argument is provided to a py.test run, the current working directory
is used to start the search.</p>
</div>
<div class="section" id="adding-default-options">
<span id="how-to-change-command-line-options-defaults"></span><span id="id1"></span><h2>How to change command line options defaults<a class="headerlink" href="#adding-default-options" title="Permalink to this headline">¶</a></h2>
<p>It can be tedious to type the same series of command line options
every time you use py.test .  For example, if you always want to see
detailed info on skipped and xfailed tests, as well as have terser &#8220;dot&#8221;
progress output, you can write it into a configuration file:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># content of pytest.ini</span>
<span class="c"># (or tox.ini or setup.cfg)</span>
<span class="p">[</span><span class="n">pytest</span><span class="p">]</span>
<span class="n">addopts</span> <span class="o">=</span> <span class="o">-</span><span class="n">rsxX</span> <span class="o">-</span><span class="n">q</span>
</pre></div>
</div>
<p>From now on, running <tt class="docutils literal"><span class="pre">py.test</span></tt> will add the specified options.</p>
</div>
<div class="section" id="builtin-configuration-file-options">
<h2>Builtin configuration file options<a class="headerlink" href="#builtin-configuration-file-options" title="Permalink to this headline">¶</a></h2>
<dl class="confval">
<dt id="confval-minversion">
<tt class="descname">minversion</tt><a class="headerlink" href="#confval-minversion" title="Permalink to this definition">¶</a></dt>
<dd><p>Specifies a minimal pytest version required for running tests.</p>
<blockquote>
<div>minversion = 2.1  # will fail if we run with pytest-2.0</div></blockquote>
</dd></dl>

<dl class="confval">
<dt id="confval-addopts">
<tt class="descname">addopts</tt><a class="headerlink" href="#confval-addopts" title="Permalink to this definition">¶</a></dt>
<dd><p>Add the specified <tt class="docutils literal"><span class="pre">OPTS</span></tt> to the set of command line arguments as if they
had been specified by the user. Example: if you have this ini file content:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">[</span><span class="n">pytest</span><span class="p">]</span>
<span class="n">addopts</span> <span class="o">=</span> <span class="o">--</span><span class="n">maxfail</span><span class="o">=</span><span class="mi">2</span> <span class="o">-</span><span class="n">rf</span>  <span class="c"># exit after 2 failures, report fail info</span>
</pre></div>
</div>
<p>issuing <tt class="docutils literal"><span class="pre">py.test</span> <span class="pre">test_hello.py</span></tt> actually means:</p>
<div class="highlight-python"><pre>py.test --maxfail=2 -rf test_hello.py</pre>
</div>
<p>Default is to add no options.</p>
</dd></dl>

<dl class="confval">
<dt id="confval-norecursedirs">
<tt class="descname">norecursedirs</tt><a class="headerlink" href="#confval-norecursedirs" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the directory basename patterns to avoid when recursing
for test discovery.  The individual (fnmatch-style) patterns are
applied to the basename of a directory to decide if to recurse into it.
Pattern matching characters:</p>
<div class="highlight-python"><pre>*       matches everything
?       matches any single character
[seq]   matches any character in seq
[!seq]  matches any char not in seq</pre>
</div>
<p>Default patterns are <tt class="docutils literal"><span class="pre">.*</span> <span class="pre">_*</span> <span class="pre">CVS</span> <span class="pre">{args}</span></tt>. Setting a <tt class="docutils literal"><span class="pre">norecursedir</span></tt>
replaces the default.  Here is an example of how to avoid
certain directories:</p>
<div class="highlight-python"><pre># content of setup.cfg
[pytest]
norecursedirs = .svn _build tmp*</pre>
</div>
<p>This would tell py.test to not look into typical subversion or
sphinx-build directories or into any <tt class="docutils literal"><span class="pre">tmp</span></tt> prefixed directory.</p>
</dd></dl>

<dl class="confval">
<dt id="confval-python_files">
<tt class="descname">python_files</tt><a class="headerlink" href="#confval-python_files" title="Permalink to this definition">¶</a></dt>
<dd><p>One or more Glob-style file patterns determining which python files
are considered as test modules.</p>
</dd></dl>

<dl class="confval">
<dt id="confval-python_classes">
<tt class="descname">python_classes</tt><a class="headerlink" href="#confval-python_classes" title="Permalink to this definition">¶</a></dt>
<dd><p>One or more name prefixes determining which test classes
are considered as test modules.</p>
</dd></dl>

<dl class="confval">
<dt id="confval-python_functions">
<tt class="descname">python_functions</tt><a class="headerlink" href="#confval-python_functions" title="Permalink to this definition">¶</a></dt>
<dd><p>One or more name prefixes determining which test functions
and methods are considered as test modules.</p>
<p>See <a class="reference internal" href="example/pythoncollection.html#change-naming-conventions"><em>Changing naming conventions</em></a> for examples.</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="assert.html" title="The writing and reporting of assertions in tests"
             >next</a></li>
        <li class="right" >
          <a href="builtin.html" title="Pytest API and builtin fixtures"
             >previous</a> |</li>
        <li><a href="contents.html">pytest-2.3.4.1</a> &raquo;</li>
          <li><a href="apiref.html" >py.test reference documentation</a> &raquo;</li>
 
<g:plusone></g:plusone>

      </ul>
    </div>

    <div class="footer">
        &copy; Copyright 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>