gawel / pyquery

A jquery-like library for python
http://pyquery.rtfd.org/
Other
2.3k stars 182 forks source link

the `html` method is over-returning on some platforms #230

Closed rjsparks closed 1 year ago

rjsparks commented 2 years ago

See https://github.com/rjsparks/test_pyquery. On some platforms q('#whatever').html() returns html beyond the id-whatever element.

=================================== FAILURES ===================================
_________________________________ test_pyquery _________________________________

    def test_pyquery():
        doc = \
    """
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <title>title</title>
      </head>
      <body>
       <table>
         <tbody>
          <tr id="too-much-before">
            <th></th>
            <td></td>
          </tr>
          <tr id="target">
            <th>Hi There</th>
            <td></td>
          </tr>
          <tr id="too-much-after">
            <th></th>
            <td></td>
        </tbody>
      </table>
      </body>
    </html>
    """
        q = PyQuery(doc)
        assert 'Hi There' in q('#target').html()
>       assert 'too-much-after' not in q('#target').html()
E       assert 'too-much-after' not in '\n        <...td/>\n      '
E         'too-much-after' is contained here:
E             <tr id="too-much-after">
E                   <th/>
E                   <td/>
E               </tr></tbody>
E             </table>
E             </body>...
E         
E         ...Full output truncated (4 lines hidden), use '-vv' to show

test_pyquery.py:32: AssertionError
=========================== short test summary info ============================
FAILED test_pyquery.py::test_pyquery - assert 'too-much-after' not in '\n    ...
============================== 1 failed in 0.04s ===============================
rjsparks commented 2 years ago

This has similarities to #227 and the (old?) #215

gawel commented 1 year ago

maybe the same as https://github.com/gawel/pyquery/issues/237

rjsparks commented 1 year ago

Have to wonder if there's an interface change that would make this less likely to stumble over.