| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 | |
| 7 """Unittests for grit.format.policy_templates.writers.admx_writer.""" | |
| 8 | |
| 9 | |
| 10 import re | |
| 11 import unittest | |
| 12 | |
| 13 | |
| 14 class XmlWriterBaseTest(unittest.TestCase): | |
| 15 '''Base class for XML writer unit-tests. | |
| 16 ''' | |
| 17 | |
| 18 def GetXMLOfChildren(self, parent): | |
| 19 '''Returns the XML of all child nodes of the given parent node. | |
| 20 Args: | |
| 21 parent: The XML of the children of this node will be returned. | |
| 22 | |
| 23 Return: XML of the chrildren of the parent node. | |
| 24 ''' | |
| 25 raw_pretty_xml = ''.join( | |
| 26 child.toprettyxml(indent=' ') for child in parent.childNodes) | |
| 27 # Python 2.6.5 which is present in Lucid has bug in its pretty print | |
| 28 # function which produces new lines around string literals. This has been | |
| 29 # fixed in Precise which has Python 2.7.3 but we have to keep compatibility | |
| 30 # with both for now. | |
| 31 text_re = re.compile('>\n\s+([^<>\s].*?)\n\s*</', re.DOTALL) | |
| 32 return text_re.sub('>\g<1></', raw_pretty_xml) | |
| 33 | |
| 34 def AssertXMLEquals(self, output, expected_output): | |
| 35 '''Asserts if the passed XML arguements are equal. | |
| 36 Args: | |
| 37 output: Actual XML text. | |
| 38 expected_output: Expected XML text. | |
| 39 ''' | |
| 40 self.assertEquals(output.strip(), expected_output.strip()) | |
| OLD | NEW |