From 404b4479a26ab89f41b2e9bae5c6ffc8d5777f67 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Mon, 1 Apr 2013 21:30:19 -0400 Subject: [PATCH] Implement the remaining asserts in TreeEqualityTestCase. --- mwparserfromhell/nodes/html_entity.py | 5 ++++- tests/_test_tree_equality.py | 18 +++++++++++++----- tests/test_builder.py | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/mwparserfromhell/nodes/html_entity.py b/mwparserfromhell/nodes/html_entity.py index 221040b..5b7607c 100644 --- a/mwparserfromhell/nodes/html_entity.py +++ b/mwparserfromhell/nodes/html_entity.py @@ -135,7 +135,10 @@ class HTMLEntity(Node): @hex_char.setter def hex_char(self, newval): - self._hex_char = bool(newval) + newval = str(newval) + if newval not in ("x", "X"): + raise ValueError(newval) + self._hex_char = newval def normalize(self): """Return the unicode character represented by the HTML entity.""" diff --git a/tests/_test_tree_equality.py b/tests/_test_tree_equality.py index 16f4b49..2014ac1 100644 --- a/tests/_test_tree_equality.py +++ b/tests/_test_tree_equality.py @@ -54,23 +54,31 @@ class TreeEqualityTestCase(TestCase): def assertArgumentNodeEqual(self, expected, actual): """Assert that two Argument nodes have the same data.""" - pass + self.assertWikicodeEqual(expected.name, actual.name) + if expected.default is not None: + self.assertWikicodeEqual(expected.default, actual.default) + else: + self.assertIs(None, actual.default) def assertCommentNodeEqual(self, expected, actual): """Assert that two Comment nodes have the same data.""" - pass + self.assertWikicodeEqual(expected.contents, actual.contents) def assertHeadingNodeEqual(self, expected, actual): """Assert that two Heading nodes have the same data.""" - pass + self.assertWikicodeEqual(expected.title, actual.title) + self.assertEqual(expected.level, actual.level) def assertHTMLEntityNodeEqual(self, expected, actual): """Assert that two HTMLEntity nodes have the same data.""" - pass + self.assertEqual(expected.value, actual.value) + self.assertIs(expected.named, actual.named) + self.assertIs(expected.hexadecimal, actual.hexadecimal) + self.assertEquals(expected.hex_char, actual.hex_char) def assertTagNodeEqual(self, expected, actual): """Assert that two Tag nodes have the same data.""" - pass + self.fail("Holding this until feature/html_tags is ready.") def assertTemplateNodeEqual(self, expected, actual): """Assert that two Template nodes have the same data.""" diff --git a/tests/test_builder.py b/tests/test_builder.py index a80d8bf..e6919c1 100644 --- a/tests/test_builder.py +++ b/tests/test_builder.py @@ -64,6 +64,7 @@ class TestBuilder(TreeEqualityTestCase): """tests for building Comment nodes""" pass + @unittest.skip("holding this until feature/html_tags is ready") def test_tag(self): """tests for building Tag nodes""" pass