[Python-checkins] r73273 - in python/branches/py3k: Lib/test/test_winreg.py Misc/NEWS

martin.v.loewis python-checkins at python.org
Sun Jun 7 19:55:18 CEST 2009


Author: martin.v.loewis
Date: Sun Jun  7 19:55:17 2009
New Revision: 73273

Log:
Issue #6221: Delete test registry key before running the test.

Modified:
   python/branches/py3k/Lib/test/test_winreg.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/test/test_winreg.py
==============================================================================
--- python/branches/py3k/Lib/test/test_winreg.py	(original)
+++ python/branches/py3k/Lib/test/test_winreg.py	Sun Jun  7 19:55:17 2009
@@ -28,6 +28,27 @@
 class WinregTests(unittest.TestCase):
     remote_name = None
 
+    def setUp(self):
+        # Make sure that the test key is absent when the test
+        # starts.
+        self.delete_tree(HKEY_CURRENT_USER, test_key_name)
+
+    def delete_tree(self, root, subkey):
+        try:
+            hkey = OpenKey(root, subkey, KEY_ALL_ACCESS)
+        except WindowsError:
+            # subkey does not exist
+            return
+        while True:
+            try:
+                subsubkey = EnumKey(hkey, 0)
+            except WindowsError:
+                # no more subkeys
+                break
+            self.delete_tree(hkey, subsubkey)
+        CloseKey(hkey)
+        DeleteKey(root, subkey)
+
     def WriteTestData(self, root_key, subkeystr="sub_key"):
         # Set the default value for this key.
         SetValue(root_key, test_key_name, REG_SZ, "Default value")

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sun Jun  7 19:55:17 2009
@@ -46,6 +46,8 @@
 Windows
 -------
 
+- Issue #6221: Delete test registry key before running the test.
+
 - Issue #6158: Package Sine-1000Hz-300ms.aif in MSI file.
 
 C-API


More information about the Python-checkins mailing list