@@ -559,6 +559,41 @@ def test_delete_tree(self):
559559 with self .assertRaises (OSError ):
560560 OpenKey (HKEY_CURRENT_USER , test_key_name )
561561
562+ def test_getvalue (self ):
563+ test_subkey = test_key_name + "\\ GetValueTest"
564+ key = CreateKey (HKEY_CURRENT_USER , test_subkey )
565+ self .addCleanup (CloseKey , key )
566+ self .addCleanup (DeleteTree , HKEY_CURRENT_USER , test_key_name )
567+
568+ SetValueEx (key , "test_string" , 0 , REG_SZ , "Hello World" )
569+ SetValueEx (key , "test_dword" , 0 , REG_DWORD , 12345 )
570+ SetValueEx (key , "test_binary" , 0 , REG_BINARY , b"binary_data" )
571+ SetValueEx (key , None , 0 , REG_SZ , "Default Value" )
572+
573+ result , typ = GetValue (HKEY_CURRENT_USER , test_subkey , "test_string" )
574+ self .assertEqual (result , "Hello World" )
575+ self .assertEqual (typ , REG_SZ )
576+
577+ result , typ = GetValue (HKEY_CURRENT_USER , test_subkey , "test_dword" )
578+ self .assertEqual (result , 12345 )
579+ self .assertEqual (typ , REG_DWORD )
580+
581+ result , typ = GetValue (HKEY_CURRENT_USER , test_subkey , "test_binary" )
582+ self .assertEqual (result , b"binary_data" )
583+ self .assertEqual (typ , REG_BINARY )
584+
585+ result , typ = GetValue (HKEY_CURRENT_USER , test_subkey , None )
586+ self .assertEqual (result , "Default Value" )
587+ self .assertEqual (typ , REG_SZ )
588+
589+ result , typ = GetValue (HKEY_CURRENT_USER , test_subkey , "" )
590+ self .assertEqual (result , "Default Value" )
591+ self .assertEqual (typ , REG_SZ )
592+
593+ result , typ = GetValue (HKEY_CURRENT_USER , test_subkey , "test_string" , RRF_RT_REG_SZ )
594+ self .assertEqual (result , "Hello World" )
595+ self .assertEqual (typ , REG_SZ )
596+
562597
563598if __name__ == "__main__" :
564599 if not REMOTE_NAME :
0 commit comments