~facelessuser/beautifulsoup/lxml-fix

« back to all changes in this revision

Viewing changes to bs4/testing.py

  • Committer: Leonard Richardson
  • Date: 2019-07-21 19:50:49 UTC
  • Revision ID: leonardr@segfault.org-20190721195049-vzupkzxai3bx3r8t
Implemented line number tracking for html5lib.

Show diffs side-by-side

added added

removed removed

Lines of Context:
790
790
        soup = self.soup(BAD_DOCUMENT)
791
791
        self.linkage_validator(soup)
792
792
 
793
 
    def test_tracking_line_numbers(self):
794
 
        # In general, TreeBuilders do not keep track of
795
 
        # line numbers from the original markup. Even if you
796
 
        # ask for line numbers, we don't have 'em.
797
 
        #
798
 
        # This means that if you have a tag like <lineno> or <offset>,
799
 
        # tag.lineno will find it rather than giving you a numeric
800
 
        # answer.
801
 
        #
802
 
        # See HTMLParserTreeBuilderSmokeTest for a situation
803
 
        # where the parser _does_ keep track of the line numbers.
804
 
        soup = self.soup(
805
 
            "\n   <p>\n\n<lineno>\n<b>text</b></lineno><offset></p>",
806
 
            store_line_numbers=True
807
 
        )
808
 
        self.assertEqual("lineno", soup.p.lineno.name)
809
 
        self.assertEqual("offset", soup.p.offset.name)
810
793
 
811
794
class XMLTreeBuilderSmokeTest(object):
812
795