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";