Index: chrome/test/mini_installer/registry_verifier.py |
diff --git a/chrome/test/mini_installer/registry_verifier.py b/chrome/test/mini_installer/registry_verifier.py |
index bd790d574823082202e3bc5c5eda561b9b2e1abb..7fe0373a70288f15df9726d1c3f14924319005d0 100644 |
--- a/chrome/test/mini_installer/registry_verifier.py |
+++ b/chrome/test/mini_installer/registry_verifier.py |
@@ -10,6 +10,11 @@ import verifier |
class RegistryVerifier(verifier.Verifier): |
"""Verifies that the current registry matches the specified criteria.""" |
+ def __init__(self): |
+ self._root_key_value = None |
+ self._is_key_forbidden = None |
+ self._sub_key = None |
+ |
def _RootKeyConstant(self, root_key): |
"""Converts a root registry key string into a _winreg.HKEY_* constant.""" |
root_key_mapping = { |
@@ -63,21 +68,23 @@ class RegistryVerifier(verifier.Verifier): |
variable_expander: A VariableExpander object. |
""" |
key = variable_expander.Expand(expectation_name) |
- root_key, sub_key = key.split('\\', 1) |
+ root_key, self._sub_key = key.split('\\', 1) |
+ self._root_key_value = self._RootKeyConstant(root_key) |
+ self._is_key_forbidden = (expectation['exists'] == 'forbidden') |
try: |
# Query the Windows registry for the registry key. It will throw a |
# WindowsError if the key doesn't exist. |
- key_handle = _winreg.OpenKey(self._RootKeyConstant(root_key), sub_key, 0, |
+ key_handle = _winreg.OpenKey(self._root_key_value, self._sub_key, 0, |
_winreg.KEY_QUERY_VALUE) |
except WindowsError: |
# Key doesn't exist. See that it matches the expectation. |
- assert expectation['exists'] != 'required', ('Registry key %s is ' |
- 'missing' % key) |
+ self._Assert(expectation['exists'] != 'required', ('Registry key %s is ' |
+ 'missing' % key)) |
# Values are not checked if the missing key's existence is optional. |
return |
# The key exists, see that it matches the expectation. |
- assert expectation['exists'] != 'forbidden', ('Registry key %s exists' % |
- key) |
+ self._Assert(expectation['exists'] != 'forbidden', |
+ ('Registry key %s exists' % key)) |
# Verify the expected values. |
if 'values' not in expectation: |