commit:     4bc191233cf98231275dc7a997e6cb67f8c81481
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jul  5 05:48:05 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Jul 12 05:05:17 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4bc19123

python-utils-r1.eclass: epytest, support --hypothesis-profile=gentoo

Support using the "gentoo" hypothesis profile, as installed
by dev-python/hypothesis-gentoo, to disable all Hypothesis health
checks.  This avoids spurious test failures, e.g. when the system is
under load and the strategies are underperforming.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Part-of: https://github.com/gentoo/gentoo/pull/42876
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index dce565b8b036..9e94acf34edf 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1518,6 +1518,17 @@ epytest() {
                fi
        fi
 
+       # If we are using hypothesis (require use via EPYTEST_PLUGINS, since
+       # ebuilds may disable autoloading manually) *and* hypothesis-gentoo
+       # is available, use it to disable all health checks, to prevent the 
tests
+       # from failing randomly under load.
+       if has hypothesis "${EPYTEST_PLUGINS[@]}" &&
+               "${EPYTHON}" -c 'import hypothesis_gentoo' 2>/dev/null &&
+               [[ ! ${HYPOTHESIS_NO_PLUGINS} ]]
+       then
+               args+=( --hypothesis-profile=gentoo )
+       fi
+
        local x
        for x in "${EPYTEST_DESELECT[@]}"; do
                args+=( --deselect "${x}" )

Reply via email to