

def test_privilege_context_manager(self):
    fake_process = mock.MagicMock()
    fake_token = True
    LUID = 'fakeid'
    self._win32process_mock.GetCurrentProcess.return_value = fake_process
    self._win32security_mock.OpenProcessToken.return_value = fake_token
    self._win32security_mock.LookupPrivilegeValue.return_value = LUID
    privilege_enabled = [(LUID, self._win32security_mock.SE_PRIVILEGE_ENABLED)]
    privilege_removed = [(LUID, self._win32security_mock.SE_PRIVILEGE_REMOVED)]
    with self.privilege_module.acquire_privilege(mock.sentinel.privilege):
        self._win32security_mock.AdjustTokenPrivileges.assert_called_with(fake_token, False, privilege_enabled)
        self._win32security_mock.OpenProcessToken.assert_called_with(fake_process, (self._win32security_mock.TOKEN_ADJUST_PRIVILEGES | self._win32security_mock.TOKEN_QUERY))
    self._win32security_mock.AdjustTokenPrivileges.assert_called_with(fake_token, False, fake_token)

dataset/ETHPy150Open openstack/cloudbase-init/cloudbaseinit/tests/utils/windows/test_privilege.py TestPrivilege.test_privilege_context_manager/VarMisuse@153/265 `privilege_removed`->`fake_token`