Skip to content
Snippets Groups Projects
Commit 292aecbb authored by brad kittenbrink's avatar brad kittenbrink
Browse files

Updated test_win32_manifest.py to throw custom exception objects, rather than...

Updated test_win32_manifest.py to throw custom exception objects, rather than relying on string comparison.
parent 0c0b59e1
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,21 @@
import tempfile
from xml.dom.minidom import parse
class AssemblyTestException(Exception):
pass
class NoManifestException(AssemblyTestException):
pass
class MultipleBindingsException(AssemblyTestException):
pass
class UnexpectedVersionException(AssemblyTestException):
pass
class NoMatchingAssemblyException(AssemblyTestException):
pass
def get_HKLM_registry_value(key_str, value_str):
import _winreg
reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
......@@ -81,7 +96,7 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver):
mt_result = os.system(system_call)
if mt_result == 31:
print "No manifest found in %s" % src_filename
raise Exception("No manifest found")
raise NoManifestException()
manifest_dom = parse(tmp_file_name)
nodes = manifest_dom.getElementsByTagName('assemblyIdentity')
......@@ -93,19 +108,19 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver):
if len(versions) == 0:
print "No matching assemblies found in %s" % src_filename
raise Exception("No matching assembly")
raise NoMatchingAssemblyException()
elif len(versions) > 1:
print "Multiple bindings to %s found:" % assembly_name
print versions
print
raise Exception("Multiple bindings")
raise MultipleBindingsException(versions)
elif versions[0] != assembly_ver:
print "Unexpected version found for %s:" % assembly_name
print "Wanted %s, found %s" % (assembly_ver, versions[0])
print
raise Exception("Unexpected version")
raise UnexpectedVersionException(assembly_ver, versions[0])
os.remove(tmp_file_name)
......
......@@ -187,6 +187,7 @@ def test_for_no_msvcrt_manifest_and_copy_action(self, src, dst):
# This is used to test that no manifest for the msvcrt exists.
# It is used as a temporary override during the construct method
from test_win32_manifest import test_assembly_binding
from test_win32_manifest import NoManifestException, NoMatchingAssemblyException
if src and (os.path.exists(src) or os.path.islink(src)):
# ensure that destination path exists
self.cmakedirs(os.path.dirname(dst))
......@@ -198,9 +199,10 @@ def test_for_no_msvcrt_manifest_and_copy_action(self, src, dst):
else:
test_assembly_binding(src, "Microsoft.VC80.CRT", "")
raise Exception("Unknown condition")
except Exception, err:
if err.message != "No matching assembly" or err.message != "No manifest found":
raise Exception("Found unexpected MSVCRT manifest binding")
except NoManifestException, err:
pass
except NoMatchingAssemblyException, err:
pass
self.ccopy(src,dst)
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment