Implement an XML matcher
Uses the "Matcher" interface of the testtools assertThat() call to compare XML document strings safely. This will result in more useful error results and will ignore attribute ordering issues that caused problems with tests affected by lxml version skew. Also converts test_libvirt_config to use XMLMatches, to demonstrate its use. Change-Id: I7821557a73eb8b5aca823cfccd02b4b660e0ffdb
This commit is contained in:
@@ -18,15 +18,13 @@ from lxml import etree
|
||||
from lxml import objectify
|
||||
|
||||
from nova import test
|
||||
|
||||
from nova.tests import matchers
|
||||
from nova.virt.libvirt import config
|
||||
|
||||
|
||||
class LibvirtConfigBaseTest(test.TestCase):
|
||||
def assertXmlEqual(self, expectedXmlstr, actualXmlstr):
|
||||
expected = etree.tostring(objectify.fromstring(expectedXmlstr))
|
||||
actual = etree.tostring(objectify.fromstring(actualXmlstr))
|
||||
self.assertEqual(expected, actual)
|
||||
self.assertThat(actualXmlstr, matchers.XMLMatches(expectedXmlstr))
|
||||
|
||||
|
||||
class LibvirtConfigTest(LibvirtConfigBaseTest):
|
||||
|
||||
Reference in New Issue
Block a user