Back to index

python3.2  3.2.2
Public Member Functions
test.test_winreg.Win64WinregTests Class Reference
Inheritance diagram for test.test_winreg.Win64WinregTests:
Inheritance graph
[legend]
Collaboration diagram for test.test_winreg.Win64WinregTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_named_arguments
def test_reflection_functions
def test_reflection
def test_disable_reflection
def setUp
def delete_tree

Detailed Description

Definition at line 330 of file test_winreg.py.


Member Function Documentation

def test.test_winreg.BaseWinregTests.delete_tree (   self,
  root,
  subkey 
) [inherited]

Definition at line 54 of file test_winreg.py.

00054 
00055     def delete_tree(self, root, subkey):
00056         try:
00057             hkey = OpenKey(root, subkey, KEY_ALL_ACCESS)
00058         except WindowsError:
00059             # subkey does not exist
00060             return
00061         while True:
00062             try:
00063                 subsubkey = EnumKey(hkey, 0)
00064             except WindowsError:
00065                 # no more subkeys
00066                 break
00067             self.delete_tree(hkey, subsubkey)
00068         CloseKey(hkey)
00069         DeleteKey(root, subkey)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_winreg.BaseWinregTests.setUp (   self) [inherited]

Definition at line 49 of file test_winreg.py.

00049 
00050     def setUp(self):
00051         # Make sure that the test key is absent when the test
00052         # starts.
00053         self.delete_tree(HKEY_CURRENT_USER, test_key_name)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 393 of file test_winreg.py.

00393 
00394     def test_disable_reflection(self):
00395         # Make use of a key which gets redirected and reflected
00396         try:
00397             with CreateKeyEx(HKEY_CURRENT_USER, test_reflect_key_name, 0,
00398                              KEY_ALL_ACCESS | KEY_WOW64_32KEY) as created_key:
00399                 # QueryReflectionKey returns whether or not the key is disabled
00400                 disabled = QueryReflectionKey(created_key)
00401                 self.assertEqual(type(disabled), bool)
00402                 # HKCU\Software\Classes is reflected by default
00403                 self.assertFalse(disabled)
00404 
00405                 DisableReflectionKey(created_key)
00406                 self.assertTrue(QueryReflectionKey(created_key))
00407 
00408             # The key is now closed and would normally be reflected to the
00409             # 64-bit area, but let's make sure that didn't happen.
00410             open_fail = lambda: OpenKeyEx(HKEY_CURRENT_USER,
00411                                           test_reflect_key_name, 0,
00412                                           KEY_READ | KEY_WOW64_64KEY)
00413             self.assertRaises(WindowsError, open_fail)
00414 
00415             # Make sure the 32-bit key is actually there
00416             with OpenKeyEx(HKEY_CURRENT_USER, test_reflect_key_name, 0,
00417                            KEY_READ | KEY_WOW64_32KEY) as key:
00418                 self.assertNotEqual(key.handle, 0)
00419         finally:
00420             DeleteKeyEx(HKEY_CURRENT_USER, test_reflect_key_name,
00421                         KEY_WOW64_32KEY, 0)
00422 

Here is the call graph for this function:

Definition at line 332 of file test_winreg.py.

00332 
00333     def test_named_arguments(self):
00334         self._test_named_args(HKEY_CURRENT_USER, test_key_name)
00335         # Clean up and also exercise the named arguments
00336         DeleteKeyEx(key=HKEY_CURRENT_USER, sub_key=test_key_name,
00337                     access=KEY_ALL_ACCESS, reserved=0)

Here is the call graph for this function:

Definition at line 349 of file test_winreg.py.

00349 
00350     def test_reflection(self):
00351         # Test that we can create, open, and delete keys in the 32-bit
00352         # area. Because we are doing this in a key which gets reflected,
00353         # test the differences of 32 and 64-bit keys before and after the
00354         # reflection occurs (ie. when the created key is closed).
00355         try:
00356             with CreateKeyEx(HKEY_CURRENT_USER, test_reflect_key_name, 0,
00357                              KEY_ALL_ACCESS | KEY_WOW64_32KEY) as created_key:
00358                 self.assertNotEqual(created_key.handle, 0)
00359 
00360                 # The key should now be available in the 32-bit area
00361                 with OpenKey(HKEY_CURRENT_USER, test_reflect_key_name, 0,
00362                              KEY_ALL_ACCESS | KEY_WOW64_32KEY) as key:
00363                     self.assertNotEqual(key.handle, 0)
00364 
00365                 # Write a value to what currently is only in the 32-bit area
00366                 SetValueEx(created_key, "", 0, REG_SZ, "32KEY")
00367 
00368                 # The key is not reflected until created_key is closed.
00369                 # The 64-bit version of the key should not be available yet.
00370                 open_fail = lambda: OpenKey(HKEY_CURRENT_USER,
00371                                             test_reflect_key_name, 0,
00372                                             KEY_READ | KEY_WOW64_64KEY)
00373                 self.assertRaises(WindowsError, open_fail)
00374 
00375             # Now explicitly open the 64-bit version of the key
00376             with OpenKey(HKEY_CURRENT_USER, test_reflect_key_name, 0,
00377                          KEY_ALL_ACCESS | KEY_WOW64_64KEY) as key:
00378                 self.assertNotEqual(key.handle, 0)
00379                 # Make sure the original value we set is there
00380                 self.assertEqual("32KEY", QueryValue(key, ""))
00381                 # Set a new value, which will get reflected to 32-bit
00382                 SetValueEx(key, "", 0, REG_SZ, "64KEY")
00383 
00384             # Reflection uses a "last-writer wins policy, so the value we set
00385             # on the 64-bit key should be the same on 32-bit
00386             with OpenKey(HKEY_CURRENT_USER, test_reflect_key_name, 0,
00387                          KEY_READ | KEY_WOW64_32KEY) as key:
00388                 self.assertEqual("64KEY", QueryValue(key, ""))
00389         finally:
00390             DeleteKeyEx(HKEY_CURRENT_USER, test_reflect_key_name,
00391                         KEY_WOW64_32KEY, 0)

Here is the call graph for this function:

Definition at line 338 of file test_winreg.py.

00338 
00339     def test_reflection_functions(self):
00340         # Test that we can call the query, enable, and disable functions
00341         # on a key which isn't on the reflection list with no consequences.
00342         with OpenKey(HKEY_LOCAL_MACHINE, "Software") as key:
00343             # HKLM\Software is redirected but not reflected in all OSes
00344             self.assertTrue(QueryReflectionKey(key))
00345             self.assertIsNone(EnableReflectionKey(key))
00346             self.assertIsNone(DisableReflectionKey(key))
00347             self.assertTrue(QueryReflectionKey(key))

Here is the call graph for this function:


The documentation for this class was generated from the following file: