mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Fix list_values, add test (#33264)
This commit is contained in:
parent
05e763c53c
commit
3b50a7b98d
@ -285,8 +285,9 @@ def list_values(hive, key=None, use_32bit_registry=False, include_default=True):
|
||||
registry = Registry()
|
||||
hkey = registry.hkeys[local_hive]
|
||||
access_mask = registry.registry_32[use_32bit_registry]
|
||||
|
||||
handle = None
|
||||
values = list()
|
||||
|
||||
try:
|
||||
handle = _winreg.OpenKey(hkey, local_key, 0, access_mask)
|
||||
|
||||
|
@ -119,6 +119,27 @@ class RegWinTestCase(TestCase):
|
||||
test = len(test_list) > 5 # Their should be a lot more than 5 items
|
||||
self.assertTrue(test)
|
||||
|
||||
@skipIf(not sys.platform.startswith("win"), "requires Windows OS")
|
||||
def test_list_values_fail(self):
|
||||
'''
|
||||
Test - List the values under a subkey which does not exist.
|
||||
'''
|
||||
subkey = 'ThisIsJunkItDoesNotExistIhope'
|
||||
test_list = win_mod_reg.list_values('HKEY_LOCAL_MACHINE', subkey)
|
||||
# returns a tuple with first item false, and second item a reason
|
||||
test = isinstance(test_list, tuple) and (not test_list[0])
|
||||
self.assertTrue(test)
|
||||
|
||||
@skipIf(not sys.platform.startswith("win"), "requires Windows OS")
|
||||
def test_list_values(self):
|
||||
'''
|
||||
Test - List the values under a subkey.
|
||||
'''
|
||||
subkey = r'Software\Microsoft\Windows NT\CurrentVersion'
|
||||
test_list = win_mod_reg.list_values('HKEY_LOCAL_MACHINE', subkey)
|
||||
test = len(test_list) > 5 # There should be a lot more than 5 items
|
||||
self.assertTrue(test)
|
||||
|
||||
# Not considering this destructive as its writing to a private space
|
||||
@skipIf(not sys.platform.startswith("win"), "requires Windows OS")
|
||||
def test_set_value_unicode(self):
|
||||
|
Loading…
Reference in New Issue
Block a user