about summary refs log tree commit diff
path: root/nixos/doc/manual/development
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2022-06-05 20:46:01 +0200
committerGitHub <noreply@github.com>2022-06-05 20:46:01 +0200
commitbad676c7ede9d615f3b545859dcc7a541b7f7659 (patch)
treed6e8a599ca7792d3146c3e429dddee7c9459566e /nixos/doc/manual/development
parentb03fed4229b7c41315d99292d50cdd3ee986a4a5 (diff)
parent793180cf557e9f5368466f62d6c54a8887895d3e (diff)
Merge pull request #174441 from tljuniper/172325-nixostest-override-python-pkgs-additional-param
nixos/test-driver: additional Python packages in test driver
Diffstat (limited to 'nixos/doc/manual/development')
-rw-r--r--nixos/doc/manual/development/writing-nixos-tests.section.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/nixos/doc/manual/development/writing-nixos-tests.section.md b/nixos/doc/manual/development/writing-nixos-tests.section.md
index 583b8f712b412..f4f4056ad9889 100644
--- a/nixos/doc/manual/development/writing-nixos-tests.section.md
+++ b/nixos/doc/manual/development/writing-nixos-tests.section.md
@@ -393,3 +393,25 @@ with foo_running:
     def foo_running():
         machine.succeed("pgrep -x foo")
     ```
+
+## Adding Python packages to the test script {#ssec-python-packages-in-test-script}
+
+When additional Python libraries are required in the test script, they can be
+added using the parameter `extraPythonPackages`. For example, you could add
+`numpy` like this:
+
+```nix
+import ./make-test-python.nix
+{
+  extraPythonPackages = p: [ p.numpy ];
+
+  nodes = { };
+
+  testScript = ''
+    import numpy as np
+    assert str(np.zeros(4) == "array([0., 0., 0., 0.])")
+  '';
+}
+```
+
+In that case, `numpy` is chosen from the generic `python3Packages`.