Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (24 sloc) 940 Bytes
##
# Tests for HTML Analysis Library
##
from htmlanalyzer import *
import unittest
class TestHTMLAnalysis(unittest.TestCase):
def setUp(self):
f = open('test.html', 'r')
html = f.read()
self.result = HTMLAnalyzer(html).analyze()
def test_countElements(self):
self.assertEqual(self.result['numIframes'], 2)
self.assertEqual(self.result['numScripts'], 6)
self.assertEqual(self.result['numScriptsWithWrongExtension'], 4)
self.assertEqual(self.result['numEmbeds'], 2)
self.assertEqual(self.result['numObjects'], 2)
self.assertEqual(self.result['numHyperlinks'], 1)
self.assertEqual(self.result['numMetaRefresh'], 1)
self.assertEqual(self.result['numHiddenElements'], 2)
self.assertEqual(self.result['numSmallElements'], 2)
self.assertEqual(self.result['hasDoubleDocuments'], True)
self.assertEqual(self.result['numIncludedUrls'], 10)
if __name__ == '__main__':
unittest.main()
Something went wrong with that request. Please try again.