diff options
author | tljuniper <48209000+tljuniper@users.noreply.github.com> | 2022-05-23 13:56:18 +0200 |
---|---|---|
committer | tljuniper <48209000+tljuniper@users.noreply.github.com> | 2022-05-29 11:22:50 +0200 |
commit | 2a750c302669a59a13d8a2a6fa038cbc6e6cb134 (patch) | |
tree | dba361531c7b0f5bc0f9085ec8d6db3a505febea /nixos/doc/manual/development | |
parent | 8858bf009e8ed2545205686945e64f0406dede9d (diff) |
nixos/manual: Add docs on extra python packages in tests
Diffstat (limited to 'nixos/doc/manual/development')
-rw-r--r-- | nixos/doc/manual/development/writing-nixos-tests.section.md | 22 |
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 e5ee1cb01ff16..fff8873e61d0d 100644 --- a/nixos/doc/manual/development/writing-nixos-tests.section.md +++ b/nixos/doc/manual/development/writing-nixos-tests.section.md @@ -380,3 +380,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`. |