| Index: tools/grit/grit/format/policy_templates/writers/xml_writer_base_unittest.py
|
| diff --git a/tools/grit/grit/format/policy_templates/writers/xml_writer_base_unittest.py b/tools/grit/grit/format/policy_templates/writers/xml_writer_base_unittest.py
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..cfa5dc268549c4fc9bee8f46f53e3b7ccf4776e5
|
| --- /dev/null
|
| +++ b/tools/grit/grit/format/policy_templates/writers/xml_writer_base_unittest.py
|
| @@ -0,0 +1,40 @@
|
| +#!/usr/bin/env python
|
| +# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +
|
| +"""Unittests for grit.format.policy_templates.writers.admx_writer."""
|
| +
|
| +
|
| +import re
|
| +import unittest
|
| +
|
| +
|
| +class XmlWriterBaseTest(unittest.TestCase):
|
| + '''Base class for XML writer unit-tests.
|
| + '''
|
| +
|
| + def GetXMLOfChildren(self, parent):
|
| + '''Returns the XML of all child nodes of the given parent node.
|
| + Args:
|
| + parent: The XML of the children of this node will be returned.
|
| +
|
| + Return: XML of the chrildren of the parent node.
|
| + '''
|
| + raw_pretty_xml = ''.join(
|
| + child.toprettyxml(indent=' ') for child in parent.childNodes)
|
| + # Python 2.6.5 which is present in Lucid has bug in its pretty print
|
| + # function which produces new lines around string literals. This has been
|
| + # fixed in Precise which has Python 2.7.3 but we have to keep compatibility
|
| + # with both for now.
|
| + text_re = re.compile('>\n\s+([^<>\s].*?)\n\s*</', re.DOTALL)
|
| + return text_re.sub('>\g<1></', raw_pretty_xml)
|
| +
|
| + def AssertXMLEquals(self, output, expected_output):
|
| + '''Asserts if the passed XML arguements are equal.
|
| + Args:
|
| + output: Actual XML text.
|
| + expected_output: Expected XML text.
|
| + '''
|
| + self.assertEquals(output.strip(), expected_output.strip())
|
|
|