diff options
Diffstat (limited to 'guide/pytest.html')
-rw-r--r-- | guide/pytest.html | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/guide/pytest.html b/guide/pytest.html index 85054e4..22299ce 100644 --- a/guide/pytest.html +++ b/guide/pytest.html @@ -1,16 +1,16 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="en" data-content_root="./"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" /> <title>pytest recipes — Gentoo Python Guide documentation</title> - <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=b3523f8e" /> + <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=4f649999" /> <link rel="stylesheet" type="text/css" href="_static/alabaster.css?v=039e1c02" /> - <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js?v=b3ba4146"></script> + <script src="_static/documentation_options.js?v=5929fcd5"></script> <script src="_static/doctools.js?v=888ff710"></script> - <script src="_static/sphinx_highlight.js?v=4825356b"></script> + <script src="_static/sphinx_highlight.js?v=dc90522c"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Advanced concepts" href="concept.html" /> @@ -32,9 +32,9 @@ <div class="body" role="main"> <section id="pytest-recipes"> -<h1>pytest recipes<a class="headerlink" href="#pytest-recipes" title="Permalink to this heading">¶</a></h1> +<h1>pytest recipes<a class="headerlink" href="#pytest-recipes" title="Link to this heading">¶</a></h1> <section id="skipping-tests-based-on-markers"> -<h2>Skipping tests based on markers<a class="headerlink" href="#skipping-tests-based-on-markers" title="Permalink to this heading">¶</a></h2> +<h2>Skipping tests based on markers<a class="headerlink" href="#skipping-tests-based-on-markers" title="Link to this heading">¶</a></h2> <p>A few packages use <a class="reference external" href="https://docs.pytest.org/en/stable/example/markers.html">custom pytest markers</a> to indicate e.g. tests requiring Internet access. These markers can be used to conveniently disable whole test groups, e.g.:</p> @@ -45,7 +45,7 @@ disable whole test groups, e.g.:</p> </div> </section> <section id="skipping-tests-based-on-paths-names"> -<h2>Skipping tests based on paths/names<a class="headerlink" href="#skipping-tests-based-on-paths-names" title="Permalink to this heading">¶</a></h2> +<h2>Skipping tests based on paths/names<a class="headerlink" href="#skipping-tests-based-on-paths-names" title="Link to this heading">¶</a></h2> <p>There are two primary methods of skipping tests based on path (and name) in pytest: using <code class="docutils literal notranslate"><span class="pre">--ignore</span></code> and <code class="docutils literal notranslate"><span class="pre">--deselect</span></code>.</p> <p><code class="docutils literal notranslate"><span class="pre">--ignore</span></code> causes pytest to entirely ignore a file or a directory @@ -87,7 +87,7 @@ requires using the local scope.</p> </div> </section> <section id="avoiding-the-dependency-on-pytest-runner"> -<h2>Avoiding the dependency on pytest-runner<a class="headerlink" href="#avoiding-the-dependency-on-pytest-runner" title="Permalink to this heading">¶</a></h2> +<h2>Avoiding the dependency on pytest-runner<a class="headerlink" href="#avoiding-the-dependency-on-pytest-runner" title="Link to this heading">¶</a></h2> <p><a class="reference external" href="https://pypi.org/project/pytest-runner/">pytest-runner</a> is a package providing <code class="docutils literal notranslate"><span class="pre">pytest</span></code> command to setuptools. While it might be convenient upstream, there is no real reason to use it in Gentoo packages. It has no real advantage over calling pytest @@ -105,7 +105,7 @@ tests. If this is the case, the dependency must be stripped.</p> </div> </section> <section id="using-pytest-xdist-to-run-tests-in-parallel"> -<h2>Using pytest-xdist to run tests in parallel<a class="headerlink" href="#using-pytest-xdist-to-run-tests-in-parallel" title="Permalink to this heading">¶</a></h2> +<h2>Using pytest-xdist to run tests in parallel<a class="headerlink" href="#using-pytest-xdist-to-run-tests-in-parallel" title="Link to this heading">¶</a></h2> <p><a class="reference external" href="https://pypi.org/project/pytest-xdist/">pytest-xdist</a> is a plugin that makes it possible to run multiple tests in parallel. This is especially useful for programs with large test suites that take significant time to run single-threaded.</p> @@ -143,7 +143,7 @@ tests are very slow while others are fast. Otherwise, the lengthy tests may end up being executed on the same thread and become a bottleneck.</p> </section> <section id="avoiding-dependencies-on-other-pytest-plugins"> -<h2>Avoiding dependencies on other pytest plugins<a class="headerlink" href="#avoiding-dependencies-on-other-pytest-plugins" title="Permalink to this heading">¶</a></h2> +<h2>Avoiding dependencies on other pytest plugins<a class="headerlink" href="#avoiding-dependencies-on-other-pytest-plugins" title="Link to this heading">¶</a></h2> <p>There is a number of pytest plugins that have little value to Gentoo users. They include plugins for test coverage (<code class="docutils literal notranslate"><span class="pre">dev-python/pytest-cov</span></code>), coding style (<code class="docutils literal notranslate"><span class="pre">dev-python/pytest-flake8</span></code>) @@ -168,7 +168,7 @@ to strip options enabling them from <code class="docutils literal notranslate">< </div> </section> <section id="explicitly-disabling-automatic-pytest-plugins"> -<h2>Explicitly disabling automatic pytest plugins<a class="headerlink" href="#explicitly-disabling-automatic-pytest-plugins" title="Permalink to this heading">¶</a></h2> +<h2>Explicitly disabling automatic pytest plugins<a class="headerlink" href="#explicitly-disabling-automatic-pytest-plugins" title="Link to this heading">¶</a></h2> <p>Besides plugins explicitly used by the package, there are a few pytest plugins that enable themselves automatically for all test suites when installed. In some cases, their presence causes tests of packages @@ -184,7 +184,7 @@ it explicitly:</p> </div> </section> <section id="expert-disabling-plugin-autoloading-entirely"> -<h2>Expert: disabling plugin autoloading entirely<a class="headerlink" href="#expert-disabling-plugin-autoloading-entirely" title="Permalink to this heading">¶</a></h2> +<h2>Expert: disabling plugin autoloading entirely<a class="headerlink" href="#expert-disabling-plugin-autoloading-entirely" title="Link to this heading">¶</a></h2> <p>If a test suite invokes pytest recursively (this is particularly the case when packaging other pytest plugins), the <code class="docutils literal notranslate"><span class="pre">-p</span></code> option can be insufficient to disable problematic plugins, as it does not @@ -209,7 +209,7 @@ the <code class="docutils literal notranslate"><span class="pre">entry_points.tx </div> </section> <section id="typeerror-make-test-flaky-got-an-unexpected-keyword-argument-reruns"> -<h2>TypeError: _make_test_flaky() got an unexpected keyword argument ‘reruns’<a class="headerlink" href="#typeerror-make-test-flaky-got-an-unexpected-keyword-argument-reruns" title="Permalink to this heading">¶</a></h2> +<h2>TypeError: _make_test_flaky() got an unexpected keyword argument ‘reruns’<a class="headerlink" href="#typeerror-make-test-flaky-got-an-unexpected-keyword-argument-reruns" title="Link to this heading">¶</a></h2> <p>If you see a test error resembling the following:</p> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>TypeError:<span class="w"> </span>_make_test_flaky<span class="o">()</span><span class="w"> </span>got<span class="w"> </span>an<span class="w"> </span>unexpected<span class="w"> </span>keyword<span class="w"> </span>argument<span class="w"> </span><span class="s1">'reruns'</span> </pre></div> @@ -232,7 +232,7 @@ python_test<span class="o">()</span><span class="w"> </span><span class="o">{</s </div> </section> <section id="importpathmismatcherror"> -<h2>ImportPathMismatchError<a class="headerlink" href="#importpathmismatcherror" title="Permalink to this heading">¶</a></h2> +<h2>ImportPathMismatchError<a class="headerlink" href="#importpathmismatcherror" title="Link to this heading">¶</a></h2> <p>An <code class="docutils literal notranslate"><span class="pre">ImportPathMismatchError</span></code> generally indicates that the same Python module (or one that supposedly looks the same) has been loaded twice using different paths, e.g.:</p> @@ -260,7 +260,7 @@ discovery to the actual test directories, e.g.:</p> </div> </section> <section id="fixture-not-found"> -<h2>fixture ‘…’ not found<a class="headerlink" href="#fixture-not-found" title="Permalink to this heading">¶</a></h2> +<h2>fixture ‘…’ not found<a class="headerlink" href="#fixture-not-found" title="Link to this heading">¶</a></h2> <p>Most of the time, a missing fixture indicates that some pytest plugin is not installed. In rare cases, it can signify an incompatible pytest version or package issue.</p> @@ -292,7 +292,7 @@ plugins.</p> </table> </section> <section id="warnings"> -<h2>Warnings<a class="headerlink" href="#warnings" title="Permalink to this heading">¶</a></h2> +<h2>Warnings<a class="headerlink" href="#warnings" title="Link to this heading">¶</a></h2> <p>pytest captures all warnings from the test suite by default, and prints a summary of them at the end of the test suite run:</p> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="o">===============================</span><span class="w"> </span>warnings<span class="w"> </span><span class="nv">summary</span><span class="w"> </span><span class="o">===============================</span> @@ -436,7 +436,7 @@ setting ignores <code class="docutils literal notranslate"><span class="pre">Dep ©2020, Michał Górny, license: CC BY 4.0. | - Powered by <a href="http://sphinx-doc.org/">Sphinx 7.1.2</a> + Powered by <a href="http://sphinx-doc.org/">Sphinx 7.2.6</a> & <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a> | |