Skip to content

Commit

Permalink
Don't try/catch when testing run
Browse files Browse the repository at this point in the history
The exception will fail the test anyways

Co-authored-by: Fernando Bravo <[email protected]>
  • Loading branch information
pedro-avalos and fernando79513 authored Dec 12, 2024
1 parent 86d4614 commit 6c97da6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions checkbox-support/checkbox_support/tests/test_lxd_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,18 @@ def test_image_download(
self.assertEqual(lxd.image, "/tmp/image")

@patch(
"subprocess.run",
"subprocess.check_output",
return_value=MagicMock(returncode=0, stdout="success", stderr=""),
)
def test_run_success(self, run_mock, logging_mock):
self_mock = MagicMock()
try:
LXD.run(self_mock, "ip a")
except subprocess.CalledProcessError:
self.fail("run raised CalledProcessError")
LXD.run(self_mock, "ip a")
run_mock.assert_called_with(
["ip", "a"],
stderr=subprocess.STDOUT,
stdin=subprocess.DEVNULL,
universal_newlines=True,
)

@patch(
"subprocess.run",
Expand Down

0 comments on commit 6c97da6

Please sign in to comment.