Skip to content

Commit

Permalink
Merge pull request #253 from gsnedders/unittest-be-gone
Browse files Browse the repository at this point in the history
Get rid of all remaining references to stdlib unittest; r=nobody!
  • Loading branch information
gsnedders committed May 20, 2016
2 parents 8cb66f2 + 1df7e5f commit c8fafd4
Show file tree
Hide file tree
Showing 4 changed files with 314 additions and 355 deletions.
6 changes: 0 additions & 6 deletions html5lib/tests/test_encoding.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
from __future__ import absolute_import, division, unicode_literals

import os
import unittest

try:
unittest.TestCase.assertEqual
except AttributeError:
unittest.TestCase.assertEqual = unittest.TestCase.assertEquals

from .support import get_data_files, test_dir, errorMessage, TestData as _TestData
from html5lib import HTMLParser, inputstream
Expand Down
73 changes: 31 additions & 42 deletions html5lib/tests/test_parser2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,52 @@

import io

import pytest

from . import support # flake8: noqa
from html5lib import html5parser
from html5lib.constants import namespaces
from html5lib import treebuilders
from html5lib import parse

import unittest

# tests that aren't autogenerated from text files
def test_assertDoctypeCloneable():
doc = parse('<!DOCTYPE HTML>', treebuilder="dom")
assert doc.cloneNode(True) is not None


class MoreParserTests(unittest.TestCase):

def setUp(self):
self.dom_tree = treebuilders.getTreeBuilder("dom")

def test_assertDoctypeCloneable(self):
parser = html5parser.HTMLParser(tree=self.dom_tree)
doc = parser.parse('<!DOCTYPE HTML>')
self.assertTrue(doc.cloneNode(True))

def test_line_counter(self):
# http:https://groups.google.com/group/html5lib-discuss/browse_frm/thread/f4f00e4a2f26d5c0
parser = html5parser.HTMLParser(tree=self.dom_tree)
parser.parse("<pre>\nx\n&gt;\n</pre>")
def test_line_counter():
# http:https://groups.google.com/group/html5lib-discuss/browse_frm/thread/f4f00e4a2f26d5c0
assert parse("<pre>\nx\n&gt;\n</pre>") is not None

def test_namespace_html_elements_0_dom(self):
parser = html5parser.HTMLParser(tree=self.dom_tree, namespaceHTMLElements=True)
doc = parser.parse("<html></html>")
self.assertTrue(doc.childNodes[0].namespaceURI == namespaces["html"])

def test_namespace_html_elements_1_dom(self):
parser = html5parser.HTMLParser(tree=self.dom_tree, namespaceHTMLElements=False)
doc = parser.parse("<html></html>")
self.assertTrue(doc.childNodes[0].namespaceURI is None)
def test_namespace_html_elements_0_dom():
doc = parse("<html></html>",
treebuilder="dom",
namespaceHTMLElements=True)
assert doc.childNodes[0].namespaceURI == namespaces["html"]

def test_namespace_html_elements_0_etree(self):
parser = html5parser.HTMLParser(namespaceHTMLElements=True)
doc = parser.parse("<html></html>")
self.assertTrue(doc.tag == "{%s}html" % (namespaces["html"],))

def test_namespace_html_elements_1_etree(self):
parser = html5parser.HTMLParser(namespaceHTMLElements=False)
doc = parser.parse("<html></html>")
self.assertTrue(doc.tag == "html")
def test_namespace_html_elements_1_dom():
doc = parse("<html></html>",
treebuilder="dom",
namespaceHTMLElements=False)
assert doc.childNodes[0].namespaceURI is None

def test_unicode_file(self):
parser = html5parser.HTMLParser()
parser.parse(io.StringIO("a"))

def test_namespace_html_elements_0_etree():
doc = parse("<html></html>",
treebuilder="etree",
namespaceHTMLElements=True)
assert doc.tag == "{%s}html" % (namespaces["html"],)

def buildTestSuite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)

def test_namespace_html_elements_1_etree():
doc = parse("<html></html>",
treebuilder="etree",
namespaceHTMLElements=False)
assert doc.tag == "html"

def main():
buildTestSuite()
unittest.main()

if __name__ == '__main__':
main()
def test_unicode_file():
assert parse(io.StringIO("a")) is not None
Loading

0 comments on commit c8fafd4

Please sign in to comment.