def test_encodingWorkingFile(self): parser = AdvancedHTMLParser(encoding='ascii') gotException = False try: parser.parseFile(self.tempFile.name) except UnicodeDecodeError as e: gotException = True assert gotException is True, 'Should have failed to parse unicode characters in ascii codec, probably not using passed encoding'
def test_ParseFile(self): parser = AdvancedHTMLParser() try: parser.parseFile(self.tempFile.name) except Exception as e: raise AssertionError('Failed to parse file, exception was: %s' %(str(e),)) testEm = parser.getElementById('farm') assert testEm , 'Failed to extract data from file parsing' assert len(testEm.children) == 2 , 'Invalid data from file parsing' assert testEm.children[0].innerHTML.strip() == 'Moo' , 'Invalid data from file parsing'