python3Packages.buildPythonPackage: default enabledTestPaths = [ "." ]

Explicitly provide a default value for the argument `enabledTestPaths`
as the current working directory (`enabledTestPaths = [ "." ]`)
to simplify overriding (making `enabledTestPaths` always specified as a
non-empty list) while preserving `pytest`'s default behaviour of
discovering tests in the current working directory.

Assert the specified `enabledTestPaths` value to be a non-empty list.
This commit is contained in:
Yueh-Shun Li
2025-08-18 04:43:19 +08:00
parent 35f1742e4f
commit 5bf25dffb6
3 changed files with 18 additions and 1 deletions
@@ -431,6 +431,17 @@ let
# Longer-term we should get rid of `checkPhase` and use `installCheckPhase`.
installCheckPhase = attrs.checkPhase;
}
// {
# `pytest` defaults to discover tests in the current directory if no paths or test items are specified.
# Provide an explicit default value to simplify overriding.
enabledTestPaths =
if attrs ? enabledTestPaths then
lib.throwIf (!lib.isList attrs.enabledTestPaths || attrs.enabledTestPaths == [ ])
"${lib.getName finalAttrs}: enabledTestPaths must be a non-empty list (default to [ \".\" ])."
attrs.enabledTestPaths
else
[ "." ];
}
//
lib.mapAttrs
(
@@ -442,7 +453,6 @@ let
(
getOptionalAttrs [
"enabledTestMarks"
"enabledTestPaths"
"enabledTests"
] attrs
)