

@mock.patch('os.path.join')
def test_get_instances_sub_dir(self, fake_path_join):

    class WindowsError(Exception):

        def __init__(self, winerror=None):
            self.winerror = winerror
    fake_dir_name = 'fake_dir_name'
    fake_windows_error = WindowsError
    fake_dir_name._pathutils.check_create_dir = mock.MagicMock(side_effect=WindowsError(pathutils.ERROR_INVALID_NAME))
    with mock.patch.object(builtins, 'WindowsError', fake_windows_error, create=True):
        self.assertRaises(exception.AdminRequired, self._pathutils._get_instances_sub_dir, fake_dir_name)

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/virt/hyperv/test_pathutils.py PathUtilsTestCase.test_get_instances_sub_dir/VarMisuse@58/95 `self`->`fake_dir_name`