Fix code incompotable with python2.7
Change-Id: I10c3ccd7572b10e4f87232832743ff52ee5e6e3d
This commit is contained in:
parent
c2d78e6b73
commit
0139a010e3
|
@ -53,7 +53,7 @@ class MountableMixin(object):
|
|||
mtab_path = os.path.join(mount_dir, 'etc/mtab')
|
||||
if os.path.islink(mtab_path):
|
||||
os.remove(mtab_path)
|
||||
with open(mtab_path, 'wt', encoding='utf-8') as f:
|
||||
with open(mtab_path, 'wt') as f:
|
||||
f.write(six.text_type(mtab))
|
||||
|
||||
def _umount_target(self, mount_dir, os_id=None, pseudo=True):
|
||||
|
|
|
@ -43,8 +43,7 @@ class TestMountableMixin(unittest2.TestCase):
|
|||
mock_os.path.join.side_effect = lambda x, y: "%s/%s" % (x, y)
|
||||
mock_utils.execute.return_value = (None, None)
|
||||
self.mxn._mount_target('fake_chroot')
|
||||
mock_open.assert_called_once_with('fake_chroot/etc/mtab', 'wt',
|
||||
encoding='utf-8')
|
||||
mock_open.assert_called_once_with('fake_chroot/etc/mtab', 'wt')
|
||||
mock_os.path.islink.assert_called_once_with('fake_chroot/etc/mtab')
|
||||
mock_os.remove.assert_called_once_with('fake_chroot/etc/mtab')
|
||||
|
||||
|
@ -99,8 +98,7 @@ none /run/shm tmpfs rw,nosuid,nodev 0 0"""
|
|||
mock_fu.mount_bind.call_args_list)
|
||||
file_handle = mock_open.return_value.__enter__.return_value
|
||||
file_handle.write.assert_called_once_with(fake_mtab)
|
||||
mock_open.assert_called_once_with('fake_chroot/etc/mtab', 'wt',
|
||||
encoding='utf-8')
|
||||
mock_open.assert_called_once_with('fake_chroot/etc/mtab', 'wt')
|
||||
mock_os.path.islink.assert_called_once_with('fake_chroot/etc/mtab')
|
||||
self.assertFalse(mock_os.remove.called)
|
||||
|
||||
|
|
Loading…
Reference in New Issue