Edgewall Software

Ticket #370: ticket370.diff

File ticket370.diff, 2.1 KB (added by cmlenz, 13 years ago)

Proposed fix

  • genshi/template/tests/directives.py

     
    974974        self.assertNotEqual(None, matches)
    975975        self.assertEqual(1, len(matches))
    976976
     977    def test_match_multiple_times1(self):
     978        # See http://genshi.edgewall.org/ticket/370
     979        tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
     980          <py:match path="body[@id='content']/h2" />
     981          <head py:match="head" />
     982          <head py:match="head" />
     983          <head />
     984          <body />
     985        </html>""")
     986        self.assertEqual("""<html>
     987          <head/>
     988          <body/>
     989        </html>""", tmpl.generate().render())
     990
     991    def test_match_multiple_times2(self):
     992        # See http://genshi.edgewall.org/ticket/370
     993        tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
     994          <py:match path="body/div[@id='properties']" />
     995          <head py:match="head" />
     996          <head py:match="head" />
     997          <head/>
     998          <body>
     999            <div id="properties">Foo</div>
     1000          </body>
     1001        </html>""")
     1002        self.assertEqual("""<html>
     1003          <head/>
     1004          <body>
     1005          </body>
     1006        </html>""", tmpl.generate().render())
     1007
    9771008    # FIXME
    9781009    #def test_match_after_step(self):
    9791010    #    tmpl = MarkupTemplate("""<div xmlns:py="http://genshi.edgewall.org/">
  • genshi/template/markup.py

     
    391391                    # Let the remaining match templates know about the last
    392392                    # event in the matched content, so they can update their
    393393                    # internal state accordingly
    394                     for test in [mt[0] for mt in match_templates]:
     394                    for test in [mt[0] for mt in match_templates[idx + 1:]]:
    395395                        test(tail[0], namespaces, ctxt, updateonly=True)
    396396
    397397                    break