From 3923c6de86cbb5eb0ac1c42e1b5a74603a617330 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Tue, 23 Jul 2024 17:22:49 +0200 Subject: Update Python Guide to 22ad9a6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- guide/.buildinfo | 2 +- guide/_sources/test.rst.txt | 26 ++++++++++++++++++++++++++ guide/_static/searchtools.js | 7 ++++--- guide/any.html | 4 ++-- guide/basic.html | 4 ++-- guide/buildsys.html | 4 ++-- guide/concept.html | 4 ++-- guide/depend.html | 4 ++-- guide/distutils-legacy.html | 4 ++-- guide/distutils.html | 4 ++-- guide/eclass.html | 7 ++++--- guide/expert-multi.html | 4 ++-- guide/genindex.html | 4 ++-- guide/helper.html | 4 ++-- guide/index.html | 5 +++-- guide/interpreter-maintenance.html | 4 ++-- guide/interpreter.html | 4 ++-- guide/migration.html | 4 ++-- guide/multi.html | 4 ++-- guide/objects.inv | Bin 896 -> 896 bytes guide/package-maintenance.html | 4 ++-- guide/porting.html | 4 ++-- guide/preface.html | 4 ++-- guide/pypi.html | 6 +++--- guide/pytest.html | 4 ++-- guide/qawarn.html | 4 ++-- guide/search.html | 4 ++-- guide/searchindex.js | 2 +- guide/single.html | 4 ++-- guide/test.html | 29 +++++++++++++++++++++++++++-- 30 files changed, 111 insertions(+), 57 deletions(-) diff --git a/guide/.buildinfo b/guide/.buildinfo index 0aebc93..82ecff5 100644 --- a/guide/.buildinfo +++ b/guide/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: ae4182fbca2b572010c7813755d8102d +config: 919a243bbb2ca255ad83ab463ca12b2e tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/guide/_sources/test.rst.txt b/guide/_sources/test.rst.txt index 0145125..1343a41 100644 --- a/guide/_sources/test.rst.txt +++ b/guide/_sources/test.rst.txt @@ -55,6 +55,9 @@ setting ``RDEPEND``, it also copies it to test dependencies. The valid values include: +- ``import-check`` for minimal import checking + using ``dev-python/pytest-import-check`` (see: `Import-checking + packages with no working tests`_) - ``pytest`` for ``dev-python/pytest`` - ``setup.py`` to call ``setup.py test`` (*deprecated*) - ``unittest`` to use built-in unittest discovery @@ -312,6 +315,29 @@ correctly (i.e. runs no less tests than the alternative) and that it does not spew too much irrelevant output. +Import-checking packages with no working tests +============================================== +If the package has no tests at all (or the tests are completely +unusable), the ``import-check`` 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. + +Since the function is based on pytest, ``EPYTEST_IGNORE`` can be used +to skip files that are intentionally non-importable. + +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 ``python`` plugin responsible for that, e.g.:: + + distutils_enable_tests import-check + + python_test() { + epytest -p no:python --import-check --pyargs foo + } + + Undesirable test dependencies ============================= There is a number of packages that are frequently listed as test diff --git a/guide/_static/searchtools.js b/guide/_static/searchtools.js index 92da3f8..b08d58c 100644 --- a/guide/_static/searchtools.js +++ b/guide/_static/searchtools.js @@ -178,7 +178,7 @@ const Search = { htmlToText: (htmlString, anchor) => { const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html'); - for (const removalQuery of [".headerlinks", "script", "style"]) { + for (const removalQuery of [".headerlink", "script", "style"]) { htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() }); } if (anchor) { @@ -328,13 +328,14 @@ const Search = { for (const [title, foundTitles] of Object.entries(allTitles)) { if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) { for (const [file, id] of foundTitles) { - let score = Math.round(100 * queryLower.length / title.length) + const score = Math.round(Scorer.title * queryLower.length / title.length); + const boost = titles[file] === title ? 1 : 0; // add a boost for document titles normalResults.push([ docNames[file], titles[file] !== title ? `${titles[file]} > ${title}` : title, id !== null ? "#" + id : "", null, - score, + score + boost, filenames[file], ]); } diff --git a/guide/any.html b/guide/any.html index 7b116c5..81ca7ee 100644 --- a/guide/any.html +++ b/guide/any.html @@ -297,7 +297,7 @@ USE conditional blocks inside -