diff options
Diffstat (limited to 'guide/test.html')
-rw-r--r-- | guide/test.html | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/guide/test.html b/guide/test.html index a564f77..6c4f10b 100644 --- a/guide/test.html +++ b/guide/test.html @@ -77,6 +77,9 @@ setting <code class="docutils literal notranslate"><span class="pre">RDEPEND</sp </div> <p>The valid values include:</p> <ul class="simple"> +<li><p><code class="docutils literal notranslate"><span class="pre">import-check</span></code> for minimal import checking +using <code class="docutils literal notranslate"><span class="pre">dev-python/pytest-import-check</span></code> (see: <a class="reference internal" href="#import-checking-packages-with-no-working-tests">Import-checking +packages with no working tests</a>)</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">pytest</span></code> for <code class="docutils literal notranslate"><span class="pre">dev-python/pytest</span></code></p></li> <li><p><code class="docutils literal notranslate"><span class="pre">setup.py</span></code> to call <code class="docutils literal notranslate"><span class="pre">setup.py</span> <span class="pre">test</span></code> (<em>deprecated</em>)</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">unittest</span></code> to use built-in unittest discovery</p></li> @@ -306,6 +309,27 @@ dependencies. However, you need to make sure that it finds all tests correctly (i.e. runs no less tests than the alternative) and that it does not spew too much irrelevant output.</p> </section> +<section id="import-checking-packages-with-no-working-tests"> +<h2>Import-checking packages with no working tests<a class="headerlink" href="#import-checking-packages-with-no-working-tests" title="Link to this heading">¶</a></h2> +<p>If the package has no tests at all (or the tests are completely +unusable), the <code class="docutils literal notranslate"><span class="pre">import-check</span></code> option can be used instead. This option +uses a dedicated pytest plugin to verify whether all installed Python +packages can be imported. This includes both Python modules +and compiled extensions, and therefore can e.g. detect undefined +symbols.</p> +<p>Since the function is based on pytest, <code class="docutils literal notranslate"><span class="pre">EPYTEST_IGNORE</span></code> can be used +to skip files that are intentionally non-importable.</p> +<p>Note that pytest will also run any tests found in the site-packages +directory. If this is undesirable, a custom test phase can explicitly +disable the default <code class="docutils literal notranslate"><span class="pre">python</span></code> plugin responsible for that, e.g.:</p> +<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>distutils_enable_tests<span class="w"> </span>import-check + +python_test<span class="o">()</span><span class="w"> </span><span class="o">{</span> +<span class="w"> </span>epytest<span class="w"> </span>-p<span class="w"> </span>no:python<span class="w"> </span>--import-check<span class="w"> </span>--pyargs<span class="w"> </span>foo +<span class="o">}</span> +</pre></div> +</div> +</section> <section id="undesirable-test-dependencies"> <h2>Undesirable test dependencies<a class="headerlink" href="#undesirable-test-dependencies" title="Link to this heading">¶</a></h2> <p>There is a number of packages that are frequently listed as test @@ -683,7 +707,7 @@ into it for the purpose of testing. Note that <code class="docutils literal not </div> </div> - <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> + <div class="sphinxsidebar" role="navigation" aria-label="Main"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">Gentoo Python Guide</a></h1> @@ -709,6 +733,7 @@ into it for the purpose of testing. Note that <code class="docutils literal not <li class="toctree-l2"><a class="reference internal" href="#why-is-running-tests-important">Why is running tests important?</a></li> <li class="toctree-l2"><a class="reference internal" href="#using-distutils-enable-tests">Using distutils_enable_tests</a></li> <li class="toctree-l2"><a class="reference internal" href="#choosing-the-correct-test-runner">Choosing the correct test runner</a></li> +<li class="toctree-l2"><a class="reference internal" href="#import-checking-packages-with-no-working-tests">Import-checking packages with no working tests</a></li> <li class="toctree-l2"><a class="reference internal" href="#undesirable-test-dependencies">Undesirable test dependencies</a></li> <li class="toctree-l2"><a class="reference internal" href="#missing-test-files-in-pypi-packages">Missing test files in PyPI packages</a></li> <li class="toctree-l2"><a class="reference internal" href="#importerrors-for-c-extensions">ImportErrors for C extensions</a></li> @@ -769,7 +794,7 @@ into it for the purpose of testing. Note that <code class="docutils literal not ©2020, Michał Górny, license: CC BY 4.0. | - Powered by <a href="https://www.sphinx-doc.org/">Sphinx 7.3.7</a> + Powered by <a href="https://www.sphinx-doc.org/">Sphinx 7.4.7</a> & <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a> | |