Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2bb3021

Browse files
committed
Try other approach to fix issue #15334.
1 parent 924ae1b commit 2bb3021

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Lib/test/test_winreg.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Test the windows specific win32reg module.
22
# Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey
33

4-
import os, sys
4+
import os, sys, errno
55
import unittest
66
from test import support
77
threading = support.import_module("threading")
@@ -289,11 +289,16 @@ def test_long_key(self):
289289
DeleteKey(HKEY_CURRENT_USER, '\\'.join((test_key_name, name)))
290290
DeleteKey(HKEY_CURRENT_USER, test_key_name)
291291

292-
@unittest.skipUnless('PROMPT' in os.environ, "Requires interactive session")
293292
def test_dynamic_key(self):
294293
# Issue2810, when the value is dynamically generated, these
295294
# throw "WindowsError: More data is available" in 2.6 and 3.1
296-
EnumValue(HKEY_PERFORMANCE_DATA, 0)
295+
try:
296+
EnumValue(HKEY_PERFORMANCE_DATA, 0)
297+
except OSError as e:
298+
if e.errno in (errno.EPERM, errno.EACCES):
299+
self.skipTest("access denied to registry key "
300+
"(are you running in a non-interactive session?)")
301+
raise
297302
QueryValueEx(HKEY_PERFORMANCE_DATA, "")
298303

299304
# Reflection requires XP x64/Vista at a minimum. XP doesn't have this stuff

0 commit comments

Comments
 (0)