def test_mkfs_ext4_no_contents(self):
with ExitStack() as resources:
tmpdir = resources.enter_context(TemporaryDirectory())
results_dir = os.path.join(tmpdir, 'results')
mock = MountMocker(results_dir)
resources.enter_context(
patch('ubuntu_image.helpers.run', mock.run))
# Create a temporary directory, but this time without contents.
contents_dir = resources.enter_context(TemporaryDirectory())
# And a fake image file.
img_file = resources.enter_context(NamedTemporaryFile())
mkfs_ext4(img_file, contents_dir)
# Because there were no contents, the `sudo cp` was never called,
# the mock's shutil.copytree() was also never called, therefore
# the results_dir was never created.
self.assertFalse(os.path.exists(results_dir))
评论列表
文章目录