Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/pkgcheck/checks/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@ def desc(self):
)


class EPyTestPluginsSuggestion(results.VersionResult, results.Info):
"""``EPYTEST_PLUGINS`` can be used to control plugins

The package could benefit from using ``EPYTEST_PLUGINS`` to specify
pytest plugins to be loaded.
"""

@property
def desc(self):
return "EPYTEST_PLUGINS can be used to control pytest plugins loaded"


class PythonCheck(Check):
"""Python eclass checks.

Expand All @@ -318,6 +330,7 @@ class PythonCheck(Check):
MisplacedEPyTestVar,
ShadowedEPyTestTimeout,
RedundantPyTestDisablePluginAutoload,
EPyTestPluginsSuggestion,
}
)

Expand Down Expand Up @@ -510,12 +523,15 @@ def check_epytest_vars(self, pkg):
line = pkg.node_str(var_node)
found_pytest_disable_plugin_autoload.append((line, lineno))

# EAPI 9+ defaults to disabled autoloading, in earlier EAPIs EPYTEST_PLUGINS does that.
if (
str(pkg.eapi) not in ("7", "8") or have_epytest_plugins
) and not have_epytest_plugin_autoload:
for line, lineno in found_pytest_disable_plugin_autoload:
yield RedundantPyTestDisablePluginAutoload(line=line, lineno=lineno + 1, pkg=pkg)
if not have_epytest_plugin_autoload:
# EAPI 9+ defaults to disabled autoloading, in earlier EAPIs EPYTEST_PLUGINS does that.
if str(pkg.eapi) not in ("7", "8") or have_epytest_plugins:
for line, lineno in found_pytest_disable_plugin_autoload:
yield RedundantPyTestDisablePluginAutoload(
line=line, lineno=lineno + 1, pkg=pkg
)
else:
yield EPyTestPluginsSuggestion(pkg=pkg)

@staticmethod
def _prepare_deps(deps: str):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"__class__": "EPyTestPluginsSuggestion", "category": "PythonCheck", "package": "EPyTestPluginsSuggestion", "version": "0"}
{"__class__": "EPyTestPluginsSuggestion", "category": "PythonCheck", "package": "EPyTestPluginsSuggestion", "version": "1"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff '--color=auto' -Naur python/PythonCheck/EPyTestPluginsSuggestion/EPyTestPluginsSuggestion-0.ebuild fixed/PythonCheck/EPyTestPluginsSuggestion/EPyTestPluginsSuggestion-0.ebuild
--- python/PythonCheck/EPyTestPluginsSuggestion/EPyTestPluginsSuggestion-0.ebuild 2025-07-26 08:47:01.430511740 +0200
+++ fixed/PythonCheck/EPyTestPluginsSuggestion/EPyTestPluginsSuggestion-0.ebuild 2025-07-26 08:53:08.525943176 +0200
@@ -10,4 +10,5 @@
LICENSE="BSD"
SLOT="0"

+EPYTEST_PLUGINS=()
distutils_enable_tests pytest
diff '--color=auto' -Naur python/PythonCheck/EPyTestPluginsSuggestion/EPyTestPluginsSuggestion-1.ebuild fixed/PythonCheck/EPyTestPluginsSuggestion/EPyTestPluginsSuggestion-1.ebuild
--- python/PythonCheck/EPyTestPluginsSuggestion/EPyTestPluginsSuggestion-1.ebuild 2025-07-26 08:46:54.907116335 +0200
+++ fixed/PythonCheck/EPyTestPluginsSuggestion/EPyTestPluginsSuggestion-1.ebuild 2025-07-26 08:53:21.533505780 +0200
@@ -10,9 +10,5 @@
LICENSE="BSD"
SLOT="0"

+EPYTEST_PLUGINS=()
distutils_enable_tests pytest
-
-python_test() {
- local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
- epytest
-}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"__class__": "ShadowedEPyTestTimeout", "category": "PythonCheck", "package": "ShadowedEPyTestTimeout", "version": "0", "line": "EPYTEST_TIMEOUT=1200", "lineno": 13}
{"__class__": "ShadowedEPyTestTimeout", "category": "PythonCheck", "package": "ShadowedEPyTestTimeout", "version": "0", "line": "EPYTEST_TIMEOUT=1200", "lineno": 14}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
diff '--color=auto' -Naur python/PythonCheck/ShadowedEPyTestTimeout/ShadowedEPyTestTimeout-0.ebuild fixed/PythonCheck/ShadowedEPyTestTimeout/ShadowedEPyTestTimeout-0.ebuild
--- python/PythonCheck/ShadowedEPyTestTimeout/ShadowedEPyTestTimeout-0.ebuild 2025-07-12 17:27:01.027875233 +0200
+++ fixed/PythonCheck/ShadowedEPyTestTimeout/ShadowedEPyTestTimeout-0.ebuild 2025-07-12 17:28:01.711247010 +0200
@@ -10,5 +10,5 @@
@@ -10,6 +10,6 @@
LICENSE="BSD"
SLOT="0"

EPYTEST_PLUGINS=()
-EPYTEST_TIMEOUT=1200
+: ${EPYTEST_TIMEOUT:=1200}
distutils_enable_tests pytest
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
EAPI=8

DISTUTILS_USE_PEP517=flit
PYTHON_COMPAT=( python3_10 )

inherit distutils-r1

DESCRIPTION="Ebuild without EPYTEST_PLUGINS"
HOMEPAGE="https://github.com/pkgcore/pkgcheck"
LICENSE="BSD"
SLOT="0"

distutils_enable_tests pytest
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
EAPI=8

DISTUTILS_USE_PEP517=flit
PYTHON_COMPAT=( python3_10 )

inherit distutils-r1

DESCRIPTION="Ebuild with old-style autoload-disable"
HOMEPAGE="https://github.com/pkgcore/pkgcheck"
LICENSE="BSD"
SLOT="0"

distutils_enable_tests pytest

python_test() {
local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
epytest
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
EAPI=8

DISTUTILS_USE_PEP517=flit
PYTHON_COMPAT=( python3_10 )

inherit distutils-r1

DESCRIPTION="Ebuild with explicit autoload"
HOMEPAGE="https://github.com/pkgcore/pkgcheck"
LICENSE="BSD"
SLOT="0"

EPYTEST_PLUGIN_AUTOLOAD=1
distutils_enable_tests pytest
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ PYTHON_COMPAT=( python3_10 )

inherit distutils-r1

DESCRIPTION="Ebuild with misplaced EPYTEST vars"
DESCRIPTION="Ebuild with shadowed EPYTEST_TIMEOUT"
HOMEPAGE="https://github.com/pkgcore/pkgcheck"
LICENSE="BSD"
SLOT="0"

EPYTEST_PLUGINS=()
EPYTEST_TIMEOUT=1200
distutils_enable_tests pytest
Loading