1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-09 09:36:20 +09:00

nixos/test-driver: improve error reporting and assertions (#390996)

This commit is contained in:
Jacek Galowicz 2025-04-26 10:26:01 +02:00 committed by GitHub
commit d0c304d4c1
Signed by: github
GPG key ID: B5690EEEBB952194
9 changed files with 118 additions and 23 deletions

View file

@ -121,8 +121,7 @@ and checks that the output is more-or-less correct:
```py
machine.start()
machine.wait_for_unit("default.target")
if not "Linux" in machine.succeed("uname"):
raise Exception("Wrong OS")
t.assertIn("Linux", machine.succeed("uname"), "Wrong OS")
```
The first line is technically unnecessary; machines are implicitly started
@ -134,6 +133,8 @@ starting them in parallel:
start_all()
```
Under the variable `t`, all assertions from [`unittest.TestCase`](https://docs.python.org/3/library/unittest.html) are available.
If the hostname of a node contains characters that can't be used in a
Python variable name, those characters will be replaced with
underscores in the variable name, so `nodes.machine-a` will be exposed