Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds a few tests for html.TermsHTMLReconstructor.

  • Loading branch information...
commit ec683f5f0825380eb797541ec1ab2d62f56e0683 1 parent a596b27
@BertrandBordage authored
View
1  terms/tests/html/TermsHTMLReconstructor/__init__.py
@@ -0,0 +1 @@
+from invalid_html import InvalidHTMLTestCase
View
46 terms/tests/html/TermsHTMLReconstructor/invalid_html.py
@@ -0,0 +1,46 @@
+import os.path
+from unittest import TestCase
+from terms.html import TermsHTMLReconstructor
+
+CURRENT_PATH = os.path.abspath(os.path.dirname(__file__))
+
+
+class InvalidHTMLTestCase(TestCase):
+ def test_start_tag(self):
+ '''
+ After being reconstructed, invalid missing start tags should be there.
+ '''
+ filename = 'valid.html'
+ valid = open(os.path.join(CURRENT_PATH, filename)).read()
+ filename = 'missing_start_tag.html'
+ invalid = open(os.path.join(CURRENT_PATH, filename)).read()
+
+ r = TermsHTMLReconstructor()
+ r.feed(invalid)
+ self.assertEqual(valid, r.out)
+
+ def test_end_tag(self):
+ '''
+ After being reconstructed, invalid missing end tags should be there.
+ '''
+ filename = 'valid.html'
+ valid = open(os.path.join(CURRENT_PATH, filename)).read()
+ filename = 'missing_end_tag.html'
+ invalid = open(os.path.join(CURRENT_PATH, filename)).read()
+
+ r = TermsHTMLReconstructor()
+ r.feed(invalid)
+ self.assertEqual(valid, r.out)
+
+ def test_start_end_tag(self):
+ '''
+ After being reconstructed, invalid start-end tags should be valid.
+ '''
+ filename = 'valid.html'
+ valid = open(os.path.join(CURRENT_PATH, filename)).read()
+ filename = 'invalid_start-end_tag.html'
+ invalid = open(os.path.join(CURRENT_PATH, filename)).read()
+
+ r = TermsHTMLReconstructor()
+ r.feed(invalid)
+ self.assertEqual(valid, r.out)
View
3  terms/tests/html/TermsHTMLReconstructor/invalid_start-end_tag.html
@@ -0,0 +1,3 @@
+<form>
+ <input type="text">
+</form>
View
3  terms/tests/html/TermsHTMLReconstructor/missing_end_tag.html
@@ -0,0 +1,3 @@
+<form>
+ <input type="text" />
+
View
3  terms/tests/html/TermsHTMLReconstructor/missing_start_tag.html
@@ -0,0 +1,3 @@
+
+ <input type="text" />
+</form>
View
3  terms/tests/html/TermsHTMLReconstructor/valid.html
@@ -0,0 +1,3 @@
+<form>
+ <input type="text" />
+</form>
View
1  terms/tests/html/__init__.py
@@ -1 +1,2 @@
from NeutralHTMLReconstructor import *
+from TermsHTMLReconstructor import *
Please sign in to comment.
Something went wrong with that request. Please try again.