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:
commit
d0c304d4c1
9 changed files with 118 additions and 23 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue