tests.overriding: modularize Python tests

Test with a pseudopackage python-package-stub.

Modularize the transforming function and testing function.
This commit is contained in:
Yueh-Shun Li
2023-10-19 06:20:06 +08:00
parent df2917cce3
commit 1653d671aa

View File

@@ -390,14 +390,33 @@ let
tests-python =
let
p = pkgs.python3Packages.xpybutil.overridePythonAttrs (_: {
dontWrapPythonPrograms = true;
});
python-package-stub = pkgs.python3Packages.callPackage (
{
buildPythonPackage,
emptyDirectory,
}:
buildPythonPackage {
pname = "python-package-stub";
version = "0.1.0";
pyproject = true;
src = emptyDirectory;
}
) { };
applyOverridePythonAttrs =
p:
p.overridePythonAttrs (previousAttrs: {
overridePythonAttrsFlag = previousAttrs.overridePythonAttrsFlag or 0 + 1;
});
in
{
overridePythonAttrs = {
expr = !lib.hasInfix "wrapPythonPrograms" p.postFixup;
expected = true;
expr = (applyOverridePythonAttrs python-package-stub).overridePythonAttrsFlag;
expected = 1;
};
overridePythonAttrs-nested = {
expr =
(applyOverridePythonAttrs (applyOverridePythonAttrs python-package-stub)).overridePythonAttrsFlag;
expected = 2;
};
};