Hi,
I am trying to familiarize with nixosTest
, ie:
checks.${system} = {
os = nixpkgs.legacyPackages.${system}.testers.nixosTest {
name = "basic-test";
nodes = {
machine = { ... }: {
imports = [ ./foo.nix ];
};
};
testScript = builtins.readFile ./tests/os.py;
};
};
The testScript
option takes in a python script, ie:
machine.start(allow_reboot=True)
with subtest("wait for boot"):
machine.wait_for_unit("default.target")
As machine
and subtest
are not defined it makes very difficult to discover methods, arguments viat the IDE, as it does not know where to load them from.
If I use:
from test_driver import subtest
machine.start(allow_reboot=True)
with subtest("wait for boot"):
machine.wait_for_unit("default.target")
it fails, as it is already defined:
nixos-test-driver-os> Running type check (enable/disable: config.skipTypeCheck)
nixos-test-driver-os> See https://nixos.org/manual/nixos/stable/#test-opt-skipTypeCheck
nixos-test-driver-os> testScriptWithTypes:61: error: Module "test_driver" has no attribute "subtest"
nixos-test-driver-os> [attr-defined]
nixos-test-driver-os> from test_driver import subtest
nixos-test-driver-os> ^
nixos-test-driver-os> testScriptWithTypes:61: error: Name "subtest" already defined on line 42
nixos-test-driver-os> [no-redef]
nixos-test-driver-os> from test_driver import subtest
nixos-test-driver-os> ^
nixos-test-driver-os> Found 2 errors in 1 file (checked 1 source file)
therefore I am assuming that the “input” script is the suffix of a predefined one.
Are there any best-practise on how to handle these scripts or install the actual package?
Thanks