Skip to content

Commit

Permalink
project: use functional abstraction to get packages fixtures in rende…
Browse files Browse the repository at this point in the history
…r tests

This ensures tests won't break as often when updating nixpkgs.
  • Loading branch information
adisbladis committed Oct 25, 2023
1 parent 6d99055 commit 7dbb3a0
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 246 deletions.
5 changes: 5 additions & 0 deletions lib/test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ let
pname = "poetry-plugin-export";
version = "1.4.0";
};

python3 = {
pname = "python3";
inherit (pkgs.python3) version;
};
};
stdenv = {
inherit isLinux isDarwin;
Expand Down
316 changes: 70 additions & 246 deletions lib/test_project.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
}:
let
inherit (project) loadPyproject loadPoetryPyproject;

# Get python packages from a set
getPkgs = set: pnames: map (pname: set.pkgs.${pname}) pnames;

in
{
loadPyproject = {
Expand Down Expand Up @@ -33,90 +37,30 @@ in
};
mainProgram = "pdm";
};
nativeBuildInputs = [
{
pname = "pdm-backend";
version = "2.1.4";
}
nativeBuildInputs = getPkgs mocks.cpythonLinux38 [
"pdm-backend"
];
pname = "pdm";
propagatedBuildInputs = [
{
pname = "blinker";
version = "1.5";
}
{
pname = "certifi";
version = "2023.05.07";
}
{
pname = "packaging";
version = "23.1";
}
{
pname = "platformdirs";
version = "3.9.1";
}
{
pname = "rich";
version = "13.3.5";
}
{
pname = "virtualenv";
version = "20.24.0";
}
{
pname = "pyproject-hooks";
version = "1.0.0";
}
{
pname = "requests-toolbelt";
version = "1.0.0";
}
{
pname = "unearth";
version = "0.9.1";
}
{
pname = "findpython";
version = "0.4.0";
}
{
pname = "tomlkit";
version = "0.12.1";
}
{
pname = "shellingham";
version = "1.5.1";
}
{
pname = "python-dotenv";
version = "1.0.0";
}
{
pname = "resolvelib";
version = "0.5.5";
}
{
pname = "installer";
version = "0.7.0";
}
{
pname = "cachecontrol";
version = "0.13.1";
}
{
pname = "tomli";
version = "2.0.1";
}
{
pname = "importlib-resources";
version = "5.12.0";
}
{
pname = "importlib-metadata";
version = "6.8.0";
}
propagatedBuildInputs = getPkgs mocks.cpythonLinux38 [
"blinker"
"certifi"
"packaging"
"platformdirs"
"rich"
"virtualenv"
"pyproject-hooks"
"requests-toolbelt"
"unearth"
"findpython"
"tomlkit"
"shellingham"
"python-dotenv"
"resolvelib"
"installer"
"cachecontrol"
"tomli"
"importlib-resources"
"importlib-metadata"
];
};
};
Expand All @@ -133,50 +77,20 @@ in
expected = {
format = "pyproject";
meta = { description = "Powerful data structures for data analysis, time series, and statistics"; };
nativeBuildInputs = [
{
pname = "meson-python";
version = "0.13.1";
}
{
pname = "meson";
version = "1.2.0";
}
{
pname = "wheel";
version = "0.41.1";
}
{
pname = "cython";
version = "0.29.36";
}
{
pname = "oldest-supported-numpy";
version = "1.0.0";
}
{
pname = "versioneer";
version = "0.29";
}
nativeBuildInputs = getPkgs mocks.cpythonLinux38 [
"meson-python"
"meson"
"wheel"
"cython"
"oldest-supported-numpy"
"versioneer"
];
pname = "pandas";
propagatedBuildInputs = [
{
pname = "numpy";
version = "1.25.1";
}
{
pname = "python-dateutil";
version = "2.8.2";
}
{
pname = "pytz";
version = "2023.3";
}
{
pname = "tzdata";
version = "2022.7";
}
propagatedBuildInputs = getPkgs mocks.cpythonLinux38 [
"numpy"
"python-dateutil"
"pytz"
"tzdata"
];
};
};
Expand Down Expand Up @@ -207,130 +121,40 @@ in
url = "https://spdx.org/licenses/MIT.html";
};
};
nativeBuildInputs = [
{
pname = "poetry-core";
version = "1.6.1";
}
nativeBuildInputs = getPkgs mocks.cpythonLinux38 [
"poetry-core"
];
pname = "poetry";
propagatedBuildInputs = [
{
pname = "build";
version = "0.10.0";
}
{
pname = "cachecontrol";
version = "0.13.1";
}
{
pname = "cleo";
version = "2.0.1";
}
{
pname = "crashtest";
version = "0.4.1";
}
{
pname = "dulwich";
version = "0.21.6";
}
{
pname = "filelock";
version = "3.12.2";
}
{
pname = "html5lib";
version = "1.1";
}
{
pname = "importlib-metadata";
version = "6.8.0";
}
{
pname = "installer";
version = "0.7.0";
}
{
pname = "jsonschema";
version = "4.18.4";
}
{
pname = "keyring";
version = "24.2.0";
}
{
pname = "lockfile";
version = "0.12.2";
}
{
pname = "packaging";
version = "23.1";
}
{
pname = "pexpect";
version = "4.8.0";
}
{
pname = "pkginfo";
version = "1.9.6";
}
{
pname = "platformdirs";
version = "3.9.1";
}
{
pname = "poetry-core";
version = "1.6.1";
}
{
pname = "poetry-plugin-export";
version = "1.4.0";
}
{
pname = "pyproject-hooks";
version = "1.0.0";
}
{
pname = "python3";
version = "3.10.12";
}
{
pname = "requests";
version = "2.31.0";
}
{
pname = "requests-toolbelt";
version = "1.0.0";
}
{
pname = "shellingham";
version = "1.5.1";
}
{
pname = "tomli";
version = "2.0.1";
}
{
pname = "tomlkit";
version = "0.12.1";
}
{
pname = "trove-classifiers";
version = "2023.7.6";
}
{
pname = "urllib3";
version = "1.26.16";
}
{
pname = "virtualenv";
version = "20.24.0";
}
{
pname = "pre-commit";
version = "3.3.3";
}
propagatedBuildInputs = getPkgs mocks.cpythonLinux38 [
"build"
"cachecontrol"
"cleo"
"crashtest"
"dulwich"
"filelock"
"html5lib"
"importlib-metadata"
"installer"
"jsonschema"
"keyring"
"lockfile"
"packaging"
"pexpect"
"pkginfo"
"platformdirs"
"poetry-core"
"poetry-plugin-export"
"pyproject-hooks"
"python3"
"requests"
"requests-toolbelt"
"shellingham"
"tomli"
"tomlkit"
"trove-classifiers"
"urllib3"
"virtualenv"
"pre-commit"
];
version = "1.4.2";
};
Expand Down

0 comments on commit 7dbb3a0

Please sign in to comment.