pyquery icon indicating copy to clipboard operation
pyquery copied to clipboard

1.4.3: test suite is failing

Open kloczek opened this issue 3 years ago • 26 comments

+ /usr/bin/python3 -B -m pytest
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.8, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: /home/tkloczko/rpmbuild/BUILD/pyquery-1.4.3
plugins: flaky-3.6.1, forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, asyncio-0.14.0, expect-1.1.0, pyfakefs-4.1.0, cov-2.11.1, mock-3.5.1, httpbin-1.0.0, xdist-2.2.1, hypothesis-6.3.1
collected 71 items

tests/test_browser.py .....                                                                                                                                          [  7%]
tests/test_pyquery.py F......................................F............FF............                                                                             [100%]

================================================================================= FAILURES =================================================================================
_________________________________________________________________________ TestUnicode.test_unicode _________________________________________________________________________

self = <tests.test_pyquery.TestUnicode testMethod=test_unicode>

    def test_unicode(self):
        xml = pq(u"<html><p>é</p></html>")
        self.assertEqual(type(xml.html()), str)
        self.assertEqual(str(xml), '<html><p>é</p></html>')
>       self.assertEqual(str(xml('p:contains("é")')), '<p>é</p>')
E       AssertionError: '<p>é</p></html>' != '<p>é</p>'
E       - <p>é</p></html>
E       + <p>é</p>

tests/test_pyquery.py:30: AssertionError
__________________________________________________________________ TestManipulating.test_val_for_textarea __________________________________________________________________

self = <tests.test_pyquery.TestManipulating testMethod=test_val_for_textarea>

    def test_val_for_textarea(self):
        d = pq(self.html3)
        self.assertEqual(d('#textarea-single').val(), 'Spam')
        self.assertEqual(d('#textarea-single').text(), 'Spam')
        d('#textarea-single').val('42')
        self.assertEqual(d('#textarea-single').val(), '42')
        # Note: jQuery still returns 'Spam' here.
        self.assertEqual(d('#textarea-single').text(), '42')

        multi_expected = '''Spam\n<b>Eggs</b>\nBacon'''
>       self.assertEqual(d('#textarea-multi').val(), multi_expected)
E       AssertionError: 'Spam\n<b>Eggs</b>\nBacon</textarea>\n    </span></html>\nBacon' != 'Spam\n<b>Eggs</b>\nBacon'
E         Spam
E         <b>Eggs</b>
E       - Bacon</textarea>
E       -     </span></html>
E         Bacon

tests/test_pyquery.py:484: AssertionError
_____________________________________________________________________ TestHTMLParser.test_replaceWith ______________________________________________________________________

self = <tests.test_pyquery.TestHTMLParser testMethod=test_replaceWith>

    def test_replaceWith(self):
        expected = '''<div class="portlet">
      <a href="/toto">TestimageMy link text</a>
      <a href="/toto2">imageMy link text 2</a>
      Behind you, a three-headed HTML&amp;dash;Entity!
    </div>'''
        d = pq(self.html)
        d('img').replace_with('image')
        val = d.__html__()
>       assert val == expected, (repr(val), repr(expected))
E       AssertionError: ('\'<div class="portlet">\
E               <a href="/toto">TestimageMy link text</a>\
E               <a href="/toto2">imageMy link text...     <a href="/toto2">imageMy link text 2</a>\
E               Behind you, a three-headed HTML&amp;dash;Entity!\
E             </div>\'')
E       assert '<div class="...ody></html>\n' == '<div class="...!\n    </div>'
E         Skipping 171 identical leading characters in diff, use -v to show
E
E         -     </div>
E         +     </div></body></html>

tests/test_pyquery.py:752: AssertionError
______________________________________________________________ TestHTMLParser.test_replaceWith_with_function _______________________________________________________________

self = <tests.test_pyquery.TestHTMLParser testMethod=test_replaceWith_with_function>

    def test_replaceWith_with_function(self):
        expected = '''<div class="portlet">
      TestimageMy link text
      imageMy link text 2
      Behind you, a three-headed HTML&amp;dash;Entity!
    </div>'''
        d = pq(self.html)
        d('a').replace_with(lambda i, e: pq(e).html())
        val = d.__html__()
>       assert val == expected, (repr(val), repr(expected))
E       AssertionError: ('\'<div class="portlet">\
E               TestimageMy link text\
E               imageMy link text 2\
E               Behind you, a three-headed...imageMy link text\
E               imageMy link text 2\
E               Behind you, a three-headed HTML&amp;dash;Entity!\
E             </div>\'')
E       assert '<div class="...ody></html>\n' == '<div class="...!\n    </div>'
E         Skipping 130 identical leading characters in diff, use -v to show
E
E         -     </div>
E         +     </div></body></html>

tests/test_pyquery.py:763: AssertionError
============================================================================= warnings summary =============================================================================
tests/test_pyquery.py::TestWebScrapping::test_get
tests/test_pyquery.py::TestWebScrapping::test_post
tests/test_pyquery.py::TestWebScrapping::test_session
tests/test_pyquery.py::TestWebScrappingTimeouts::test_get
  /usr/lib/python3.8/site-packages/waitress/adjustments.py:441: DeprecationWarning: In future versions of Waitress clear_untrusted_proxy_headers will be set to True by default. You may opt-out by setting this value to False, or opt-in explicitly by setting this to True.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
FAILED tests/test_pyquery.py::TestUnicode::test_unicode - AssertionError: '<p>é</p></html>' != '<p>é</p>'
FAILED tests/test_pyquery.py::TestManipulating::test_val_for_textarea - AssertionError: 'Spam\n<b>Eggs</b>\nBacon</textarea>\n    </span></html>\nBacon' != 'Spam\n<b>Egg...
FAILED tests/test_pyquery.py::TestHTMLParser::test_replaceWith - AssertionError: ('\'<div class="portlet">\
FAILED tests/test_pyquery.py::TestHTMLParser::test_replaceWith_with_function - AssertionError: ('\'<div class="portlet">\
================================================================= 4 failed, 67 passed, 4 warnings in 5.89s =================================================================

kloczek avatar Feb 24 '21 10:02 kloczek

the last travis build passed but 3.8 was not included https://travis-ci.org/github/gawel/pyquery/builds/745042291

needs to switch to github actions and add 3.8

gawel avatar Feb 24 '21 11:02 gawel

OK however do you have any guess what it may be? :)

kloczek avatar Feb 24 '21 11:02 kloczek

not at all. maybe it's not related to 3.8 but some changes in a third party library

gawel avatar Feb 24 '21 13:02 gawel

well, it's passing https://github.com/gawel/pyquery/runs/1971496711?check_suite_focus=true

gawel avatar Feb 24 '21 15:02 gawel

ok, pyquery still use nosetest... I guess the issue is related with pytest

gawel avatar Feb 24 '21 15:02 gawel

@kloczek is that a blocker for you? not sure I can find some times to switch to pytest soon. Can be tricky because doctest uses nose fixtures

gawel avatar Feb 25 '21 09:02 gawel

No it is not. For now I've disabled only executing test suite on building my package and added only note in my BTS to not loose refference to this ticket. Nevertheless no rush .. take your time :)

kloczek avatar Feb 25 '21 09:02 kloczek

tests now use pytest. if you want to give it a try.

gawel avatar Mar 08 '21 15:03 gawel

Just tested with 1.4.3 + git patches and test suite still is failing:

[tkloczko@barrel SPECS]$ rpmbuild -ba --with check python-pyquery.spec
warning: Downloading https://github.com/gawel/pyquery//archive/1.4.3/python-pyquery-1.4.3.tar.gz to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-1.4.3.tar.gz
warning: Downloading https://github.com/gawel/pyquery//commit/de94bc4f.patch#/python-pyquery-Back-to-development-1.4.4.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-Back-to-development-1.4.4.patch
warning: Downloading https://github.com/gawel/pyquery//commit/4fa57305.patch#/python-pyquery-implement-nextUntil-and-write-tests-nextAll-and-next.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-implement-nextUntil-and-write-tests-nextAll-and-next.patch
warning: Downloading https://github.com/gawel/pyquery//commit/70cbdf25.patch#/python-pyquery-gha.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-gha.patch
warning: Downloading https://github.com/gawel/pyquery//commit/eeb99fc4.patch#/python-pyquery-typo.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-typo.patch
warning: Downloading https://github.com/gawel/pyquery//commit/b7c5783a.patch#/python-pyquery-use-correct-path.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-use-correct-path.patch
warning: Downloading https://github.com/gawel/pyquery//commit/afda0b47.patch#/python-pyquery-order-matter.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-order-matter.patch
warning: Downloading https://github.com/gawel/pyquery//commit/25edcd3d.patch#/python-pyquery-use-3.8.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-use-3.8.patch
warning: Downloading https://github.com/gawel/pyquery//commit/1b9fdd94.patch#/python-pyquery-flake8.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-flake8.patch
warning: Downloading https://github.com/gawel/pyquery//commit/e5b884a3.patch#/python-pyquery-use-pytest.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-use-pytest.patch
warning: Downloading https://github.com/gawel/pyquery//commit/6173f6f8.patch#/python-pyquery-add-test-s-extra_require.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-add-test-s-extra_require.patch
warning: Downloading https://github.com/gawel/pyquery//commit/75a0b45b.patch#/python-pyquery-ignore-waitress-s-deprecationwarning.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-ignore-waitress-s-deprecationwarning.patch
warning: Downloading https://github.com/gawel/pyquery//commit/8be763c6.patch#/python-pyquery-ignore-sphinx-conf.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-ignore-sphinx-conf.patch
warning: Downloading https://github.com/gawel/pyquery//commit/f31e86b8.patch#/python-pyquery-fix-tests-changes.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyquery-fix-tests-changes.patch
warning: Macro expanded in comment on line 23: %{name}-skip-test-requiring-net-connection.patch

warning: Macro expanded in comment on line 9: %{version}.tar.gz

warning: Macro expanded in comment on line 23: %{name}-skip-test-requiring-net-connection.patch

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.zY2FcC
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ cd /home/tkloczko/rpmbuild/BUILD
+ rm -rf pyquery-1.4.3
+ /usr/bin/gzip -dc /home/tkloczko/rpmbuild/SOURCES/python-pyquery-1.4.3.tar.gz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd pyquery-1.4.3
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-Back-to-development-1.4.4.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-implement-nextUntil-and-write-tests-nextAll-and-next.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-gha.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-typo.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-use-correct-path.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-order-matter.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-use-3.8.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-flake8.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-use-pytest.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-add-test-s-extra_require.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-ignore-waitress-s-deprecationwarning.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-ignore-sphinx-conf.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyquery-fix-tests-changes.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch
+ RPM_EC=0

[..]

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pyquery-1.4.3-3.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pyquery-1.4.3-3.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/python3 -Bm pytest -ra


=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.9, pytest-6.2.3, py-1.10.0, pluggy-0.13.1
rootdir: /home/tkloczko/rpmbuild/BUILD/pyquery-1.4.3, configfile: pytest.ini
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, asyncio-0.14.0, expect-1.1.0, cov-2.11.1, mock-3.5.1, httpbin-1.0.0, xdist-2.2.1, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, pyfakefs-4.4.0, freezegun-0.4.2, flaky-3.7.0, cases-3.4.6, hypothesis-6.10.0
collected 150 items

README.rst F                                                                                                                                                         [  0%]
docs/attributes.rst .                                                                                                                                                [  1%]
docs/css.rst .                                                                                                                                                       [  2%]
docs/manipulating.rst F                                                                                                                                              [  2%]
docs/pseudo_classes.rst .                                                                                                                                            [  3%]
docs/scrap.rst .                                                                                                                                                     [  4%]
docs/tips.rst .                                                                                                                                                      [  4%]
docs/traversing.rst .                                                                                                                                                [  5%]
pyquery/cssselectpatch.py ...........................                                                                                                                [ 23%]
pyquery/pyquery.py .FF..........F......F.................F.                                                                                                          [ 50%]
tests/doctests.rst .                                                                                                                                                 [ 50%]
tests/test_browser.py .....                                                                                                                                          [ 54%]
tests/test_pyquery.py F........................................F............FF.............                                                                          [100%]

================================================================================= FAILURES =================================================================================
___________________________________________________________________________ [doctest] README.rst ___________________________________________________________________________
055 Now d is like the $ in jquery::
056
057     >>> d("#hello")
058     [<p#hello.hello>]
059     >>> p = d("#hello")
060     >>> print(p.html())
061     Hello world !
062     >>> p.html("you know <a href='http://python.org/'>Python</a> rocks")
063     [<p#hello.hello>]
064     >>> print(p.html())
Expected:
    you know <a href="http://python.org/">Python</a> rocks
Got:
    you know <a href="http://python.org/">Python</a> rocks</p>
    <BLANKLINE>
    <p id="test">
    hello <a href="http://python.org">python</a> !
    </p>
    </body>
    </html> rocks

/home/tkloczko/rpmbuild/BUILD/pyquery-1.4.3/README.rst:64: DocTestFailure
________________________________________________________________________ [doctest] manipulating.rst ________________________________________________________________________
026     >>> p.prependTo(d('#test'))
027     [<p#hello.hello>]
028     >>> print(d('#test').html())
029     <p class="hello" ...
030
031 Insert an element after another::
032
033     >>> p.insertAfter(d('#test'))
034     [<p#hello.hello>]
035     >>> print(d('#test').html())
Expected:
    <a href="http://python.org">python</a> !
Got:
    <a href="http://python.org">python</a> !</div><p class="hello" id="hello">check out <a href="http://reddit.com/r/python">reddit</a>you know Python rocks check out <a href="http://reddit.com/r/python"><span>reddit</span></a></p></body></html> !

/home/tkloczko/rpmbuild/BUILD/pyquery-1.4.3/docs/manipulating.rst:35: DocTestFailure
________________________________________________________________ [doctest] pyquery.pyquery.PyQuery.__html__ ________________________________________________________________
352 html representation of current nodes::
353
354             >>> html = PyQuery(
355             ...   '<script><![[CDATA[ ]></script>', parser='html_fragments')
356             >>> print(html.__html__())
Expected:
    <script><![[CDATA[ ]></script>
Got:
    <script><![[CDATA[ ]></script></body></html>
    <BLANKLINE>

/home/tkloczko/rpmbuild/BUILD/pyquery-1.4.3/pyquery/pyquery.py:356: DocTestFailure
________________________________________________________________ [doctest] pyquery.pyquery.PyQuery.__str__ _________________________________________________________________
336 xml representation of current nodes::
337
338             >>> xml = PyQuery(
339             ...   '<script><![[CDATA[ ]></script>', parser='html_fragments')
340             >>> print(str(xml))
Expected:
    <script>&lt;![[CDATA[ ]&gt;</script>
Got:
    <script>&lt;![[CDATA[ ]&gt;</script></body></html>

/home/tkloczko/rpmbuild/BUILD/pyquery-1.4.3/pyquery/pyquery.py:340: DocTestFailure
__________________________________________________________________ [doctest] pyquery.pyquery.PyQuery.html __________________________________________________________________
1060 Get or set the html representation of sub nodes.
1061
1062         Get the text value::
1063
1064             >>> d = PyQuery('<div><span>toto</span></div>')
1065             >>> print(d.html())
Expected:
    <span>toto</span>
Got:
    <span>toto</span></div>

/home/tkloczko/rpmbuild/BUILD/pyquery-1.4.3/pyquery/pyquery.py:1065: DocTestFailure
_______________________________________________________________ [doctest] pyquery.pyquery.PyQuery.outer_html _______________________________________________________________
1120 Get the html representation of the first selected element::
1121
1122             >>> d = PyQuery('<div><span class="red">toto</span> rocks</div>')
1123             >>> print(d('span'))
Expected:
    <span class="red">toto</span> rocks
Got:
    <span class="red">toto</span> rocks</div> rocks

/home/tkloczko/rpmbuild/BUILD/pyquery-1.4.3/pyquery/pyquery.py:1123: DocTestFailure
________________________________________________________________ [doctest] pyquery.pyquery.PyQuery.wrap_all ________________________________________________________________
1351 Wrap all the elements in the matched set into a single wrapper
1352         element::
1353
1354             >>> d = PyQuery('<div><span>Hey</span><span>you !</span></div>')
1355             >>> print(d('span').wrap_all('<div id="wrapper"></div>'))
Expected:
    <div id="wrapper"><span>Hey</span><span>you !</span></div>
Got:
    <div id="wrapper"><span>Hey</span><span>you !</span></div></div>

/home/tkloczko/rpmbuild/BUILD/pyquery-1.4.3/pyquery/pyquery.py:1355: DocTestFailure
_________________________________________________________________________ TestUnicode.test_unicode _________________________________________________________________________

self = <tests.test_pyquery.TestUnicode testMethod=test_unicode>

    def test_unicode(self):
        xml = pq(u"<html><p>é</p></html>")
        self.assertEqual(type(xml.html()), str)
        self.assertEqual(str(xml), '<html><p>é</p></html>')
>       self.assertEqual(str(xml('p:contains("é")')), '<p>é</p>')
E       AssertionError: '<p>é</p></html>' != '<p>é</p>'
E       - <p>é</p></html>
E       + <p>é</p>

tests/test_pyquery.py:29: AssertionError
__________________________________________________________________ TestManipulating.test_val_for_textarea __________________________________________________________________

self = <tests.test_pyquery.TestManipulating testMethod=test_val_for_textarea>

    def test_val_for_textarea(self):
        d = pq(self.html3)
        self.assertEqual(d('#textarea-single').val(), 'Spam')
        self.assertEqual(d('#textarea-single').text(), 'Spam')
        d('#textarea-single').val('42')
        self.assertEqual(d('#textarea-single').val(), '42')
        # Note: jQuery still returns 'Spam' here.
        self.assertEqual(d('#textarea-single').text(), '42')

        multi_expected = '''Spam\n<b>Eggs</b>\nBacon'''
>       self.assertEqual(d('#textarea-multi').val(), multi_expected)
E       AssertionError: 'Spam\n<b>Eggs</b>\nBacon</textarea>\n    </span></html>\nBacon' != 'Spam\n<b>Eggs</b>\nBacon'
E         Spam
E         <b>Eggs</b>
E       - Bacon</textarea>
E       -     </span></html>
E         Bacon

tests/test_pyquery.py:534: AssertionError
_____________________________________________________________________ TestHTMLParser.test_replaceWith ______________________________________________________________________

self = <tests.test_pyquery.TestHTMLParser testMethod=test_replaceWith>

    def test_replaceWith(self):
        expected = '''<div class="portlet">
      <a href="/toto">TestimageMy link text</a>
      <a href="/toto2">imageMy link text 2</a>
      Behind you, a three-headed HTML&amp;dash;Entity!
    </div>'''
        d = pq(self.html)
        d('img').replace_with('image')
        val = d.__html__()
>       assert val == expected, (repr(val), repr(expected))
E       AssertionError: ('\'<div class="portlet">\
E               <a href="/toto">TestimageMy link text</a>\
E               <a href="/toto2">imageMy link text...     <a href="/toto2">imageMy link text 2</a>\
E               Behind you, a three-headed HTML&amp;dash;Entity!\
E             </div>\'')
E       assert '<div class="...ody></html>\n' == '<div class="...!\n    </div>'
E         Skipping 171 identical leading characters in diff, use -v to show
E
E         -     </div>
E         +     </div></body></html>

tests/test_pyquery.py:802: AssertionError
______________________________________________________________ TestHTMLParser.test_replaceWith_with_function _______________________________________________________________

self = <tests.test_pyquery.TestHTMLParser testMethod=test_replaceWith_with_function>

    def test_replaceWith_with_function(self):
        expected = '''<div class="portlet">
      TestimageMy link text
      imageMy link text 2
      Behind you, a three-headed HTML&amp;dash;Entity!
    </div>'''
        d = pq(self.html)
        d('a').replace_with(lambda i, e: pq(e).html())
        val = d.__html__()
>       assert val == expected, (repr(val), repr(expected))
E       AssertionError: ('\'<div class="portlet">\
E               TestimageMy link text\
E               imageMy link text 2\
E               Behind you, a three-headed...imageMy link text\
E               imageMy link text 2\
E               Behind you, a three-headed HTML&amp;dash;Entity!\
E             </div>\'')
E       assert '<div class="...ody></html>\n' == '<div class="...!\n    </div>'
E         Skipping 130 identical leading characters in diff, use -v to show
E
E         -     </div>
E         +     </div></body></html>

tests/test_pyquery.py:813: AssertionError
========================================================================= short test summary info ==========================================================================
FAILED README.rst::README.rst
FAILED docs/manipulating.rst::manipulating.rst
FAILED pyquery/pyquery.py::pyquery.pyquery.PyQuery.__html__
FAILED pyquery/pyquery.py::pyquery.pyquery.PyQuery.__str__
FAILED pyquery/pyquery.py::pyquery.pyquery.PyQuery.html
FAILED pyquery/pyquery.py::pyquery.pyquery.PyQuery.outer_html
FAILED pyquery/pyquery.py::pyquery.pyquery.PyQuery.wrap_all
FAILED tests/test_pyquery.py::TestUnicode::test_unicode - AssertionError: '<p>é</p></html>' != '<p>é</p>'
FAILED tests/test_pyquery.py::TestManipulating::test_val_for_textarea - AssertionError: 'Spam\n<b>Eggs</b>\nBacon</textarea>\n    </span></html>\nBacon' != 'Spam\n<b>Egg...
FAILED tests/test_pyquery.py::TestHTMLParser::test_replaceWith - AssertionError: ('\'<div class="portlet">\
FAILED tests/test_pyquery.py::TestHTMLParser::test_replaceWith_with_function - AssertionError: ('\'<div class="portlet">\
===================================================================== 11 failed, 139 passed in 51.27s ======================================================================

kloczek avatar Apr 25 '21 18:04 kloczek

BTW: docs/conf.py is with exec attribute

kloczek avatar Apr 25 '21 18:04 kloczek

can you test with master ? this should have been fixed already

gawel avatar Apr 26 '21 06:04 gawel

can you test with master ? this should have been fixed already

If you will look closer you may see that I've applied on top 1.4.3 all commits except those which are related to CI/travis and still test suite is failing.

kloczek avatar Apr 26 '21 09:04 kloczek

yeah... those errors are super weird. I don't understand how you get those extra closing tags included.

gawel avatar Apr 26 '21 09:04 gawel

Is it anything what I ican do to try to diagnose that?🤔

kloczek avatar Apr 26 '21 10:04 kloczek

Here is my output using tox (I dont have the same exact python version):

tox -e py38 -r
GLOB sdist-make: /home/gawel/py/pyquery/setup.py
py38 recreate: /home/gawel/py/pyquery/.tox/py38
py38 installdeps: selenium, -e.[test]
py38 inst: /home/gawel/py/pyquery/.tox/.tmp/package/1/pyquery-1.4.4.dev0.zip
py38 installed: attrs==20.3.0,beautifulsoup4==4.9.3,certifi==2020.12.5,chardet==4.0.0,coverage==5.5,cssselect==1.1.0,idna==2.10,iniconfig==1.1.1,lxml==4.6.3,packaging==20.9,pluggy==0.13.1,py==1.10.0,pyparsing==2.4.7,pyquery @ file:///home/gawel/py/pyquery/.tox/.tmp/package/1/pyquery-1.4.4.dev0.zip,pytest==6.2.3,pytest-cov==2.11.1,requests==2.25.1,selenium==3.141.0,six==1.15.0,soupsieve==2.2.1,toml==0.10.2,urllib3==1.26.4,waitress==2.0.0,WebOb==1.8.7,WebTest==2.0.35
py38 run-test-pre: PYTHONHASHSEED='2011553045'
py38 runtests: commands[0] | pytest
====================================================================================== test session starts ======================================================================================
platform linux -- Python 3.8.2, pytest-6.2.3, py-1.10.0, pluggy-0.13.1
cachedir: .tox/py38/.pytest_cache
rootdir: /home/gawel/py/pyquery, configfile: pytest.ini
plugins: cov-2.11.1
collected 150 items                                                                                                                                                                             

README.rst .                                                                                                                                                                              [  0%]
docs/attributes.rst .                                                                                                                                                                     [  1%]
docs/css.rst .                                                                                                                                                                            [  2%]
docs/manipulating.rst .                                                                                                                                                                   [  2%]
docs/pseudo_classes.rst .                                                                                                                                                                 [  3%]
docs/scrap.rst .                                                                                                                                                                          [  4%]
docs/tips.rst .                                                                                                                                                                           [  4%]
docs/traversing.rst .                                                                                                                                                                     [  5%]
pyquery/cssselectpatch.py ...........................                                                                                                                                     [ 23%]
pyquery/pyquery.py ........................................                                                                                                                               [ 50%]
tests/doctests.rst .                                                                                                                                                                      [ 50%]
tests/test_browser.py .....                                                                                                                                                               [ 54%]
tests/test_pyquery.py .....................................................................                                                                                               [100%]

====================================================================================== 150 passed in 9.19s ======================================================================================
____________________________________________________________________________________________ summary ____________________________________________________________________________________________
  py38: commands succeeded
  congratulations :)

You can check your pip freeze to see if you got any differences

You can try using tox to see if you get the same errors (with your python versions/distro)

gawel avatar Apr 26 '21 10:04 gawel

In Fedora, this seems to be caused by the difference between libxml2 2.9.10 and 2.9.12.

hroncok avatar May 19 '21 09:05 hroncok

Looks like lxml is using 2.9.10 in the build process:

Preparing to unpack .../11-libxml2-dev_2.9.10+dfsg-5+ubuntu18.04.1+deb.sury.org+3_amd64.deb ...

https://github.com/lxml/lxml/runs/2618555701?check_suite_focus=true

gawel avatar May 19 '21 09:05 gawel

And 2.9.12 was released only 6 days ago (and don't seems to introduce major changes). Not sure it's the problem

gawel avatar May 19 '21 10:05 gawel

Can this be closed? If not, what is the TODO?

cclauss avatar Dec 31 '22 12:12 cclauss

I don't think that this was ever fixed. The TODO would probably be to fix the tests, no?

hroncok avatar Dec 31 '22 12:12 hroncok

GitHub Actions and tox run the pytests successfully 15 times on every pull request.

cclauss avatar Dec 31 '22 13:12 cclauss

With libxml2 2.9.12?

hroncok avatar Dec 31 '22 13:12 hroncok

Not sure. I guess it use a wheel with libxml2 included. Don't know which version

gawel avatar Dec 31 '22 13:12 gawel

libxml2 v2.10.3 is the current release... https://gitlab.gnome.org/GNOME/libxml2/-/releases

cclauss avatar Dec 31 '22 15:12 cclauss

libxml2 v4.9.2 is the current release... https://github.com/lxml/lxml/blob/master/CHANGES.txt

nope :) we are talking about libxml2, not lxml.

libxml2 2.10.0 is mentioned in the CHANGES. looks like it fix a bug with 2.9.1. So maybe the bug is still in 2.9.12 ?

gawel avatar Dec 31 '22 15:12 gawel

Just tested 2.0.0 and looks like now pytest is failing in one unit

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pyquery-2.0.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pyquery-2.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.8.17, pytest-7.4.0, pluggy-1.2.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pyquery-2.0.0
configfile: pytest.ini
collected 151 items

README.rst .                                                             [  0%]
docs/attributes.rst .                                                    [  1%]
docs/css.rst .                                                           [  1%]
docs/manipulating.rst .                                                  [  2%]
docs/pseudo_classes.rst .                                                [  3%]
docs/scrap.rst .                                                         [  3%]
docs/tips.rst .                                                          [  4%]
docs/traversing.rst .                                                    [  5%]
pyquery/cssselectpatch.py ...........................                    [ 23%]
pyquery/pyquery.py ........................................              [ 49%]
tests/doctests.rst .                                                     [ 50%]
tests/test_browser.py .....                                              [ 53%]
tests/test_pyquery.py .................................................. [ 86%]
...........F........                                                     [100%]

=================================== FAILURES ===================================
_____________________ TestXMLNamespace.test_selector_html ______________________

self = <tests.test_pyquery.TestXMLNamespace testMethod=test_selector_html>

    def test_selector_html(self):
        expected = 'What'
        d = pq('blah', self.xml.split('?>', 1)[1], parser='html')
        val = d.text()
>       self.assertEqual(repr(val), repr(expected))
E       AssertionError: "''" != "'What'"
E       - ''
E       + 'What'

tests/test_pyquery.py:862: AssertionError
=========================== short test summary info ============================
FAILED tests/test_pyquery.py::TestXMLNamespace::test_selector_html - Assertio...
======================== 1 failed, 150 passed in 7.15s =========================

kloczek avatar Aug 10 '23 14:08 kloczek