Skip to content

Commit

Permalink
tests: improve tests for shutil.which() == None
Browse files Browse the repository at this point in the history
  • Loading branch information
dbungert committed Sep 8, 2023
1 parent ae75835 commit f4082a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 9 additions & 9 deletions probert/tests/test_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,17 @@ async def test_get_device_filesystem_sizing_ext4_no_min(self):
actual = await get_device_filesystem(self.device, True)
self.assertEqual(expected, actual)

@patch('probert.filesystem.shutil.which')
async def test_ntfsresize_not_found(self, which):
which.return_value = None

@patch('probert.filesystem.shutil.which', new=Mock(return_value=None))
class TestFilesystemToolNotFound(IsolatedAsyncioTestCase):
def setUp(self):
self.device = Mock()

async def test_ntfsresize_not_found(self):
self.assertEqual(None, await get_ntfs_sizing(self.device))

@patch('probert.filesystem.shutil.which')
async def test_dumpe2fs_not_found(self, which):
which.return_value = None
async def test_dumpe2fs_not_found(self):
self.assertEqual(None, await get_dumpe2fs_info(self.device))

@patch('probert.filesystem.shutil.which')
async def test_resize2fs_not_found(self, which):
which.return_value = None
async def test_resize2fs_not_found(self):
self.assertEqual(None, await get_resize2fs_info(self.device))
6 changes: 6 additions & 0 deletions probert/tests/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,9 @@ async def test_run_once(self, run):
self.assertEqual({}, await probe())
self.assertEqual({}, await probe())
run.assert_called_once()


@patch('probert.filesystem.shutil.which', new=Mock(return_value=None))
class TestOsProberNotFound(IsolatedAsyncioTestCase):
async def test_os_prober_not_found(self):
self.assertEqual(None, _run_os_prober())

0 comments on commit f4082a2

Please sign in to comment.