Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #132: add test for #115, single character fragments #264

Merged
merged 2 commits into from
Jun 6, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! Fix #132: add test for #115, single character fragments
  • Loading branch information
gsnedders committed Jun 6, 2016
commit 7c0077567957037013ecadc8798edc499c234b84
28 changes: 6 additions & 22 deletions html5lib/tests/test_treewalkers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import absolute_import, division, unicode_literals

import itertools

import pytest

try:
Expand Down Expand Up @@ -100,36 +102,18 @@ def test_treewalker_six_mix():
yield runTreewalkerEditTest, intext, expected, attrs, tree


@pytest.mark.parametrize("tree", sorted(treeTypes.items()))
def test_fragment_single_char(tree):
expected = [
{'data': 'x', 'type': 'Characters'}
]

treeName, treeClass = tree
if treeClass is None:
pytest.skip("Treebuilder not loaded")

parser = html5parser.HTMLParser(tree=treeClass["builder"])
document = parser.parseFragment("x")
document = treeClass.get("adapter", lambda x: x)(document)
output = Lint(treeClass["walker"](document))

assert list(output) == expected


@pytest.mark.parametrize("tree", sorted(treeTypes.items()))
def test_fragment_single_non_ascii_char(tree):
@pytest.mark.parametrize("tree,char", itertools.product(sorted(treeTypes.items()), ["x", "\u1234"]))
def test_fragment_single_char(tree, char):
expected = [
{'data': '\u1234', 'type': 'Characters'}
{'data': char, 'type': 'Characters'}
]

treeName, treeClass = tree
if treeClass is None:
pytest.skip("Treebuilder not loaded")

parser = html5parser.HTMLParser(tree=treeClass["builder"])
document = parser.parseFragment("\u1234")
document = parser.parseFragment(char)
document = treeClass.get("adapter", lambda x: x)(document)
output = Lint(treeClass["walker"](document))

Expand Down