Sophie

Sophie

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

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>Usages and Examples</title>
    
    <link rel="stylesheet" href="../_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.3.4.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="None" href="../index.html" />
    <link rel="next" title="Demo of Python failure reports with py.test" href="reportingdemo.html" />
    <link rel="prev" title="Working with plugins and conftest files" href="../plugins.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="reportingdemo.html" title="Demo of Python failure reports with py.test"
             accesskey="N">next</a></li>
        <li class="right" >
          <a href="../plugins.html" title="Working with plugins and conftest files"
             accesskey="P">previous</a> |</li>
        <li><a href="../contents.html">pytest-2.3.4.1</a> &raquo;</li>
 
<g:plusone></g:plusone>

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

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

  <h4>Previous topic</h4>
  <p class="topless"><a href="../plugins.html"
                        title="previous chapter">Working with plugins and conftest files</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="reportingdemo.html"
                        title="next chapter">Demo of Python failure reports with py.test</a></p>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="usages-and-examples">
<span id="examples"></span><h1>Usages and Examples<a class="headerlink" href="#usages-and-examples" title="Permalink to this headline">ΒΆ</a></h1>
<p>Here is a (growing) list of examples. <a class="reference internal" href="../contact.html#contact"><em>Contact</em></a> us if you
need more examples or have questions. Also take a look at the
<a class="reference internal" href="../contents.html#toc"><em>comprehensive documentation</em></a> which contains many example
snippets as well.  Also, <a class="reference external" href="http://stackoverflow.com/search?q=pytest">pytest on stackoverflow.com</a> often comes with example
answers.</p>
<p>For basic examples, see</p>
<ul class="simple">
<li><a class="reference internal" href="../getting-started.html"><em>Installation and Getting Started</em></a> for basic introductory examples</li>
<li><a class="reference internal" href="../assert.html#assert"><em>Asserting with the assert statement</em></a> for basic assertion examples</li>
<li><a class="reference internal" href="../fixture.html#fixtures"><em>pytest fixtures: explicit, modular, scalable</em></a> for basic fixture/setup examples</li>
<li><a class="reference internal" href="../parametrize.html#parametrize"><em>Parametrizing fixtures and test functions</em></a> for basic test function parametrization</li>
<li><a class="reference internal" href="../unittest.html"><em>Support for unittest.TestCase / Integration of fixtures</em></a> for basic unittest integration</li>
<li><a class="reference internal" href="../nose.html"><em>Running tests written for nose</em></a> for basic nosetests integration</li>
</ul>
<p>The following examples aim at various use cases you might encounter.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="reportingdemo.html">Demo of Python failure reports with py.test</a></li>
<li class="toctree-l1"><a class="reference internal" href="simple.html">Basic patterns and examples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="simple.html#pass-different-values-to-a-test-function-depending-on-command-line-options">Pass different values to a test function, depending on command line options</a></li>
<li class="toctree-l2"><a class="reference internal" href="simple.html#dynamically-adding-command-line-options">Dynamically adding command line options</a></li>
<li class="toctree-l2"><a class="reference internal" href="simple.html#control-skipping-of-tests-according-to-command-line-option">Control skipping of tests according to command line option</a></li>
<li class="toctree-l2"><a class="reference internal" href="simple.html#writing-well-integrated-assertion-helpers">Writing well integrated assertion helpers</a></li>
<li class="toctree-l2"><a class="reference internal" href="simple.html#detect-if-running-from-within-a-py-test-run">Detect if running from within a py.test run</a></li>
<li class="toctree-l2"><a class="reference internal" href="simple.html#adding-info-to-test-report-header">Adding info to test report header</a></li>
<li class="toctree-l2"><a class="reference internal" href="simple.html#profiling-test-duration">profiling test duration</a></li>
<li class="toctree-l2"><a class="reference internal" href="simple.html#incremental-testing-test-steps">incremental testing - test steps</a></li>
<li class="toctree-l2"><a class="reference internal" href="simple.html#package-directory-level-fixtures-setups">Package/Directory-level fixtures (setups)</a></li>
<li class="toctree-l2"><a class="reference internal" href="simple.html#post-process-test-reports-failures">post-process test reports / failures</a></li>
<li class="toctree-l2"><a class="reference internal" href="simple.html#making-test-result-information-available-in-fixtures">Making test result information available in fixtures</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="parametrize.html">Parametrizing tests</a><ul>
<li class="toctree-l2"><a class="reference internal" href="parametrize.html#generating-parameters-combinations-depending-on-command-line">Generating parameters combinations, depending on command line</a></li>
<li class="toctree-l2"><a class="reference internal" href="parametrize.html#a-quick-port-of-testscenarios">A quick port of &#8220;testscenarios&#8221;</a></li>
<li class="toctree-l2"><a class="reference internal" href="parametrize.html#deferring-the-setup-of-parametrized-resources">Deferring the setup of parametrized resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="parametrize.html#parametrizing-test-methods-through-per-class-configuration">Parametrizing test methods through per-class configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="parametrize.html#indirect-parametrization-with-multiple-fixtures">Indirect parametrization with multiple fixtures</a></li>
<li class="toctree-l2"><a class="reference internal" href="parametrize.html#indirect-parametrization-of-optional-implementations-imports">Indirect parametrization of optional implementations/imports</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="markers.html">Working with custom markers</a><ul>
<li class="toctree-l2"><a class="reference internal" href="markers.html#marking-test-functions-and-selecting-them-for-a-run">Marking test functions and selecting them for a run</a></li>
<li class="toctree-l2"><a class="reference internal" href="markers.html#using-k-expr-to-select-tests-based-on-their-name">Using <tt class="docutils literal"><span class="pre">-k</span> <span class="pre">expr</span></tt> to select tests based on their name</a></li>
<li class="toctree-l2"><a class="reference internal" href="markers.html#registering-markers">Registering markers</a></li>
<li class="toctree-l2"><a class="reference internal" href="markers.html#marking-whole-classes-or-modules">Marking whole classes or modules</a></li>
<li class="toctree-l2"><a class="reference internal" href="markers.html#custom-marker-and-command-line-option-to-control-test-runs">Custom marker and command line option to control test runs</a></li>
<li class="toctree-l2"><a class="reference internal" href="markers.html#reading-markers-which-were-set-from-multiple-places">Reading markers which were set from multiple places</a></li>
<li class="toctree-l2"><a class="reference internal" href="markers.html#marking-platform-specific-tests-with-pytest">marking platform specific tests with pytest</a></li>
<li class="toctree-l2"><a class="reference internal" href="markers.html#automatically-adding-markers-based-on-test-names">Automatically adding markers based on test names</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="special.html">A sesssion-fixture which can look at all collected tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="pythoncollection.html">Changing standard (Python) test discovery</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pythoncollection.html#changing-directory-recursion">Changing directory recursion</a></li>
<li class="toctree-l2"><a class="reference internal" href="pythoncollection.html#changing-naming-conventions">Changing naming conventions</a></li>
<li class="toctree-l2"><a class="reference internal" href="pythoncollection.html#interpreting-cmdline-arguments-as-python-packages">Interpreting cmdline arguments as Python packages</a></li>
<li class="toctree-l2"><a class="reference internal" href="pythoncollection.html#finding-out-what-is-collected">Finding out what is collected</a></li>
<li class="toctree-l2"><a class="reference internal" href="pythoncollection.html#customizing-test-collection-to-find-all-py-files">customizing test collection to find all .py files</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="nonpython.html">Working with non-python tests</a><ul>
<li class="toctree-l2"><a class="reference internal" href="nonpython.html#a-basic-example-for-specifying-tests-in-yaml-files">A basic example for specifying tests in Yaml files</a></li>
</ul>
</li>
</ul>
</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="reportingdemo.html" title="Demo of Python failure reports with py.test"
             >next</a></li>
        <li class="right" >
          <a href="../plugins.html" title="Working with plugins and conftest files"
             >previous</a> |</li>
        <li><a href="../contents.html">pytest-2.3.4.1</a> &raquo;</li>
 
<g:plusone></g:plusone>

      </ul>
    </div>

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

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

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

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

  </body>
</html>