From f2e350b5b30b68d54d9b3a3924c8f54aace95ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Sun, 16 Feb 2025 18:56:09 +0100 Subject: [PATCH] python312Packages.pytest-textual-snapshot: install resources --- .../pytest-textual-snapshot/default.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkgs/development/python-modules/pytest-textual-snapshot/default.nix b/pkgs/development/python-modules/pytest-textual-snapshot/default.nix index 30ffa1b09144..0ca041371171 100644 --- a/pkgs/development/python-modules/pytest-textual-snapshot/default.nix +++ b/pkgs/development/python-modules/pytest-textual-snapshot/default.nix @@ -28,6 +28,17 @@ buildPythonPackage rec { nativeBuildInputs = [ poetry-core ]; buildInputs = [ pytest ]; + # The script looks for `resources/snapshot_report_template.jinja2` in the parent folder which + # is lib/python3.X/site-packages + # Let's avoid to have a random 'resources' folder in the PYTHONPATH. + # Instead, we move this `resources` folder in `$out/share` (see postInstall below) and patch the + # path in the script. + postPatch = '' + substituteInPlace pytest_textual_snapshot.py \ + --replace-fail \ + "this_file_path.parent" \ + "Path('$out/share/pytest-textual-snapshot/')" + ''; propagatedBuildInputs = [ jinja2 @@ -45,6 +56,11 @@ buildPythonPackage rec { pythonImportsCheck = [ "pytest_textual_snapshot" ]; + postInstall = '' + mkdir -p $out/share/pytest-textual-snapshot/ + cp -r resources $out/share/pytest-textual-snapshot/ + ''; + meta = with lib; { description = "Snapshot testing for Textual applications"; homepage = "https://github.com/Textualize/pytest-textual-snapshot";