From 2763749dec5be9c6a279cf6c5e23a89f1f98b2c0 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Fri, 22 Feb 2013 19:29:12 +0000 Subject: libvirt: lxml behavior breaks version check. lxml doesn't roundtrip empty strings, meaning if you serialize and element with value '', when you derserialize it, the value will be `None`. This broke the version_string_with_package check because None and '' will not compare as equivalent. The solution is to coerce the None value back to an empty string before running the check. Change-Id: Ia3a8ae68f12a4645057d243fdee59197df40e8d3 --- nova/tests/test_libvirt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index b1135902d..aecefb496 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1912,7 +1912,9 @@ class LibvirtConnTestCase(test.TestCase): check = (lambda t: t.findall(xpath)[2].get("name"), "version") check_list.append(check) - check = (lambda t: t.findall(xpath)[2].text, + # NOTE(sirp): empty strings don't roundtrip in lxml (they are + # converted to None), so we need an `or ''` to correct for that + check = (lambda t: t.findall(xpath)[2].text or '', version.version_string_with_package()) check_list.append(check) -- cgit