MCPcopy Index your code
hub / github.com/clips/pattern / test_wikipedia_article_sections

Method test_wikipedia_article_sections

test/test_web.py:665–695  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

663 print "pattern.web.WikipediaArticle"
664
665 def test_wikipedia_article_sections(self):
666 # Assert WikipediaArticle.sections structure.
667 # The test may need to be modified if the Wikipedia "Cat" article changes.
668 source, license, Engine = self.api["Wikipedia"]
669 v = Engine(license).search("cat", cached=False)
670 s1 = s2 = s3 = None
671 for section in v.sections:
672 if section.title == "Behavior":
673 s1 = section
674 if section.title == "Grooming":
675 s2 = section
676 if section.title == "Play":
677 s3 = section
678 self.assertTrue(section.article == v)
679 self.assertTrue(section.level == 0 or section.string.startswith(section.title))
680 # Test section depth.
681 self.assertTrue(s1.level == 1)
682 self.assertTrue(s2.level == 2)
683 self.assertTrue(s2.level == 2)
684 # Test section parent-child structure.
685 self.assertTrue(s2 in s1.children) # Behavior => Grooming
686 self.assertTrue(s3 in s1.children) # Behavior => Play
687 self.assertTrue(s2.parent == s1)
688 self.assertTrue(s3.parent == s1)
689 # Test section content.
690 self.assertTrue("hairballs" in s2.content)
691 self.assertTrue("laser pointer" in s3.content)
692 # Test section tables.
693 # XXX should test <td colspan="x"> more thoroughly.
694 self.assertTrue(len(v.sections[1].tables) > 0)
695 print "pattern.web.WikipediaSection"
696
697 def test_products(self):
698 # Assert product reviews and score.

Callers

nothing calls this directly

Calls 2

lenFunction · 0.85
searchMethod · 0.45

Tested by

no test coverage detected