Skip to content

Commit 3e629eb

Browse files
committed
test: use pytest.raises in test_empty_jailer_id
It's shorter and gives nicer error messages than `assert False` in a `try` block. Signed-off-by: Patrick Roy <[email protected]>
1 parent 1313719 commit 3e629eb

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

tests/integration_tests/security/test_jail.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,14 @@ def test_empty_jailer_id(uvm_plain):
6464
exec_file=test_microvm.fc_binary_path,
6565
)
6666

67-
# pylint: disable=W0703
68-
try:
67+
# If the exception is not thrown, it means that Firecracker was
68+
# started successfully, hence there's a bug in the code due to which
69+
# we can set an empty ID.
70+
with pytest.raises(
71+
ChildProcessError,
72+
match=r"Jailer error: Invalid instance ID: Invalid len \(0\); the length must be between 1 and 64",
73+
):
6974
test_microvm.spawn()
70-
# If the exception is not thrown, it means that Firecracker was
71-
# started successfully, hence there's a bug in the code due to which
72-
# we can set an empty ID.
73-
assert False
74-
except Exception as err:
75-
expected_err = (
76-
"Jailer error: Invalid instance ID: Invalid len (0);"
77-
" the length must be between 1 and 64"
78-
)
79-
assert expected_err in str(err)
8075

8176

8277
def test_exec_file_not_exist(uvm_plain, tmp_path):

0 commit comments

Comments
 (0)