def test_umount(self): # # umount failure # path = '/somewhere' self.assertRaises(Exception, main.unmount, path) # # umount successfully # def remove_directory_successfully(path): return True path = '/somewhere' patcher = patch('os.rmdir') rm_directory = patcher.start() rm_directory.side_effect = remove_directory_successfully with patch.multiple( main, rm_directory, command_check_call=lambda cmd: True, ): main.unmount(path)