From f526297d1384ebb5a1c154986e7fd882f586cacb Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Fri, 13 Jul 2012 22:46:41 +0200 Subject: [PATCH] Try other approach to fix issue #15334. --- Lib/test/test_winreg.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py index 629c0aa5611..bdf4e14b765 100644 --- a/Lib/test/test_winreg.py +++ b/Lib/test/test_winreg.py @@ -1,7 +1,7 @@ # Test the windows specific win32reg module. # Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey -import os, sys +import os, sys, errno import unittest from test import test_support threading = test_support.import_module("threading") @@ -280,11 +280,16 @@ class LocalWinregTests(BaseWinregTests): DeleteKey(key, name) DeleteKey(HKEY_CURRENT_USER, test_key_name) - @unittest.skipUnless('PROMPT' in os.environ, "Requires interactive session") def test_dynamic_key(self): # Issue2810, when the value is dynamically generated, these # throw "WindowsError: More data is available" in 2.6 and 3.1 - EnumValue(HKEY_PERFORMANCE_DATA, 0) + try: + EnumValue(HKEY_PERFORMANCE_DATA, 0) + except OSError as e: + if e.errno in (errno.EPERM, errno.EACCES): + self.skipTest("access denied to registry key " + "(are you running in a non-interactive session?)") + raise QueryValueEx(HKEY_PERFORMANCE_DATA, None) # Reflection requires XP x64/Vista at a minimum. XP doesn't have this stuff