Ejemplo n.º 1
0
 def test_do_not_get_text_above_from_plain_string_in_parent(self):
     code_node = get_code_node(
         "<html>",
         "  <body>",
         "    <div>Text before<code>This is code</code></div>",
         "  </body>",
         "</html>",
     )
     text = extract_text_above(code_node)
     self.assertIsNone(text)
Ejemplo n.º 2
0
 def test_get_none_if_no_text_above(self):
     code_node = get_code_node(
         "<html>",
         "  <body>",
         "    <code>This is code</code>",
         "  </body>",
         "</html>",
     )
     text = extract_text_above(code_node)
     self.assertIsNone(text)
Ejemplo n.º 3
0
 def test_get_text_above_from_p(self):
     code_node = get_code_node(
         "<html>",
         "  <body>",
         "    <p>Text above</p>",
         "    <code>This is code</code>",
         "  </body>",
         "</html>",
     )
     text = extract_text_above(code_node)
     self.assertEqual(text, "Text above")
Ejemplo n.º 4
0
 def test_get_none_if_no_text_below_header_above(self):
     code_node = get_code_node(
         "<html>",
         "  <body>",
         "    <p>Text above</p>",
         "    <h2>Header</h2>",
         "    <code>This is code</code>",
         "  </body>",
         "</html>",
     )
     text = extract_text_above(code_node)
     self.assertIsNone(text)
Ejemplo n.º 5
0
 def test_get_text_above_from_p_multiple_siblings_away(self):
     code_node = get_code_node(
         "<html>",
         "  <body>",
         "    <p>Text above</p>",
         "    <script>var i = 0;</script>",
         "    <code>This is code</code>",
         "  </body>",
         "</html>",
     )
     text = extract_text_above(code_node)
     self.assertEqual(text, "Text above")