diff --git a/mwparserfromhell/parser/builder.py b/mwparserfromhell/parser/builder.py
index 4b468b7..5ec0780 100644
--- a/mwparserfromhell/parser/builder.py
+++ b/mwparserfromhell/parser/builder.py
@@ -170,7 +170,7 @@ class Builder(object):
self._write(self._handle_token(token))
def _handle_comment(self):
- """Handle a case where a hidden comment is at the head of the tokens."""
+ """Handle a case where an HTML comment is at the head of the tokens."""
self._push()
while self._tokens:
token = self._tokens.pop()
diff --git a/tests/_test_tree_equality.py b/tests/_test_tree_equality.py
index 52130ed..2828147 100644
--- a/tests/_test_tree_equality.py
+++ b/tests/_test_tree_equality.py
@@ -91,7 +91,24 @@ class TreeEqualityTestCase(TestCase):
def assertTagNodeEqual(self, expected, actual):
"""Assert that two Tag nodes have the same data."""
- self.fail("Holding this until feature/html_tags is ready.")
+ self.assertEqual(expected.type, actual.type)
+ self.assertWikicodeEqual(expected.tag, actual.tag)
+ if expected.contents is not None:
+ self.assertWikicodeEqual(expected.contents, actual.contents)
+ length = len(expected.attributes)
+ self.assertEqual(length, len(actual.attributes))
+ for i in range(length):
+ exp_attr = expected.attributes[i]
+ act_attr = actual.attributes[i]
+ self.assertWikicodeEqual(exp_attr.name, act_attr.name)
+ if exp_attr.value is not None:
+ self.assertWikicodeEqual(exp_attr.value, act_attr.value)
+ self.assertIs(exp_attr.quoted, act_attr.quoted)
+ self.assertEqual(exp.attr.padding, act_attr.padding)
+ self.assertIs(expected.showtag, actual.showtag)
+ self.assertIs(expected.self_closing, actual.self_closing)
+ self.assertEqual(expected.padding, actual.padding)
+ self.assertWikicodeEqual(expected.closing_tag, actual.closing_tag)
def assertTemplateNodeEqual(self, expected, actual):
"""Assert that two Template nodes have the same data."""
diff --git a/tests/test_attribute.py b/tests/test_attribute.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/test_builder.py b/tests/test_builder.py
index 903d144..85a8c60 100644
--- a/tests/test_builder.py
+++ b/tests/test_builder.py
@@ -190,10 +190,18 @@ class TestBuilder(TreeEqualityTestCase):
for test, valid in tests:
self.assertWikicodeEqual(valid, self.builder.build(test))
- @unittest.skip("holding this until feature/html_tags is ready")
def test_tag(self):
"""tests for building Tag nodes"""
- pass
+ tests = [
+ ([tokens.TagOpenOpen(showtag=True, type=101),
+ tokens.Text(text="ref"), tokens.TagCloseOpen(padding=""),
+ tokens.TagOpenClose(), tokens.Text(text="ref"),
+ tokens.TagCloseClose()],
+ wrap([Tag(101, wraptext("ref"), wrap([]), [], True, False, "",
+ wraptext("ref"))])),
+ ]
+ for test, valid in tests:
+ self.assertWikicodeEqual(valid, self.builder.build(test))
def test_integration(self):
"""a test for building a combination of templates together"""
diff --git a/tests/test_tag.py b/tests/test_tag.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/tokenizer/tags.mwtest b/tests/tokenizer/tags.mwtest
new file mode 100644
index 0000000..9a6ce30
--- /dev/null
+++ b/tests/tokenizer/tags.mwtest
@@ -0,0 +1,88 @@
+name: basic
+label: a basic tag with an open and close
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
+
+---
+
+name: basic_selfclosing
+label: a basic self-closing tag
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagCloseSelfclose(padding="")]
+
+---
+
+name: content
+label: a tag with some content in the middle
+input: "[this is a reference]"
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagCloseOpen(padding=""), Text(text="this is a reference"), TagOpenClose(), Text(text="ref"), TagCloseClose()]
+
+---
+
+name: padded_open
+label: a tag with some padding in the open tag
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagCloseOpen(padding=" "), TagOpenClose(), Text(text="ref"), TagCloseClose()]
+
+---
+
+name: padded_close
+label: a tag with some padding in the close tag
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref "), TagCloseClose()]
+
+---
+
+name: padded_selfclosing
+label: a self-closing tag with padding
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagCloseSelfclose(padding=" ")]
+
+---
+
+name: attribute
+label: a tag with a single attribute
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagAttrStart(padding=""), Text(text="name"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
+
+---
+
+name: attribute_value
+label: a tag with a single attribute with a value
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagAttrStart(padding=""), Text(text="name"), TagAttrEquals(), Text(text="foo"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
+
+---
+
+name: attribute_quoted
+label: a tag with a single quoted attribute
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagAttrStart(padding=""), Text(text="name"), TagAttrEquals(), TagAttrQuote(), Text(text="foo"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
+
+---
+
+name: attribute_hyphen
+label: a tag with a single attribute, containing a hyphen
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagAttrStart(padding=""), Text(text="name"), TagAttrEquals(), Text(text="foo-bar"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
+
+---
+
+name: attribute_quoted_hyphen
+label: a tag with a single quoted attribute, containing a hyphen
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagAttrStart(padding=""), Text(text="name"), TagAttrEquals(), TagAttrQuote(), Text(text="foo-bar"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
+
+---
+
+name: attribute_selfclosing
+label: a self-closing tag with a single attribute
+input: ""
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagAttrStart(padding=""), Text(text="name"), TagCloseSelfclose(padding="")]
+
+---
+
+name: attribute_selfclosing_value
+label: a self-closing tag with a single attribute with a value
+input: "["
+output: [TagOpenOpen(showtag=True, type=101), Text(text="ref"), TagAttrStart(padding=""), Text(text="name"), TagAttrEquals(), Text(text="foo"), TagCloseSelfclose(padding="")]
]