Use "--force-reruns" rather than "--reruns" when available. This ensures that the rerun count is respected for all tests, including tests already marked upstream for reruns. Otherwise tests marked "@pytest.mark.flaky" will get rerun only once.
Signed-off-by: Michał Górny <[email protected]> --- eclass/python-utils-r1.eclass | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index e213273a3a785..b08dbd586ba88 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1538,9 +1538,17 @@ epytest() { ) fi - args+=( - "--reruns=${EPYTEST_RERUNS}" - ) + if has_version ">=dev-python/pytest-rerunfailures-16.1"; then + args+=( + # --reruns only adds N reruns for tests not marked for reruns + # --force-reruns overrides the rerun count for all tests + "--force-reruns=${EPYTEST_RERUNS}" + ) + else + args+=( + "--reruns=${EPYTEST_RERUNS}" + ) + fi fi if [[ -n ${EPYTEST_TIMEOUT} ]]; then
