Bug 2033555 - python-parsel fails to build with Python 3.11: AttributeError: 'SelectorTestCase' object has no attribute 'assertEquals'
Summary: python-parsel fails to build with Python 3.11: AttributeError: 'SelectorTestC...
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Fedora
Classification: Fedora
Component: python-parsel
Version: 36
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Igor Raits
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.11
TreeView+ depends on / blocked
 
Reported: 2021-12-17 09:08 UTC by Tomáš Hrnčiar
Modified: 2022-02-10 14:18 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-02-10 14:17:51 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2021-12-17 09:08:36 UTC
python-parsel fails to build with Python 3.11.0a3.

=================================== FAILURES ===================================
__________________ SelectorTestCase.test_accessing_attributes __________________

self = <test_selector.SelectorTestCase testMethod=test_accessing_attributes>

        def test_accessing_attributes(self):
            body = u"""
    <html lang="en" version="1.0">
        <body>
            <ul id="some-list" class="list-cls" class="list-cls">
                <li class="item-cls" id="list-item-1">
                <li class="item-cls active" id="list-item-2">
                <li class="item-cls" id="list-item-3">
            </ul>
        </body>
    </html>
            """
            sel = self.sscls(text=body)
>           self.assertEquals({'lang': 'en', 'version': '1.0'}, sel.attrib)
E           AttributeError: 'SelectorTestCase' object has no attribute 'assertEquals'

tests/test_selector.py:117: AttributeError
_______________ SelectorTestCase.test_bodies_with_comments_only ________________

self = <test_selector.SelectorTestCase testMethod=test_bodies_with_comments_only>

    def test_bodies_with_comments_only(self):
        sel = self.sscls(text=u'<!-- hello world -->', base_url='http://example.com')
>       self.assertEquals(u'http://example.com', sel.root.base)
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertEquals'

tests/test_selector.py:579: AttributeError
_____________________ SelectorTestCase.test_boolean_result _____________________

self = <test_selector.SelectorTestCase testMethod=test_boolean_result>

    def test_boolean_result(self):
        body = u"<p><input name='a'value='1'/><input name='b'value='2'/></p>"
        xs = self.sscls(text=body)
>       self.assertEquals(xs.xpath("//input[@name='a']/@name='a'").extract(), [u'1'])
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertEquals'

tests/test_selector.py:252: AttributeError
________________ SelectorTestCase.test_check_text_argument_type ________________

self = <test_selector.SelectorTestCase testMethod=test_check_text_argument_type>

    def test_check_text_argument_type(self):
>       self.assertRaisesRegexp(TypeError, 'text argument should be of type',
                                self.sscls, b'<html/>')
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertRaisesRegexp'

tests/test_selector.py:159: AttributeError
___________________ SelectorTestCase.test_configure_base_url ___________________

self = <test_selector.SelectorTestCase testMethod=test_configure_base_url>

    def test_configure_base_url(self):
        sel = self.sscls(text=u'nothing', base_url='http://example.com')
>       self.assertEquals(u'http://example.com', sel.root.base)
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertEquals'

tests/test_selector.py:695: AttributeError
____________ SelectorTestCase.test_http_header_encoding_precedence _____________

self = <test_selector.SelectorTestCase testMethod=test_http_header_encoding_precedence>

    def test_http_header_encoding_precedence(self):
        # u'\xa3'     = pound symbol in unicode
        # u'\xc2\xa3' = pound symbol in utf-8
        # u'\xa3'     = pound symbol in latin-1 (iso-8859-1)
    
        text = u'''<html>
        <head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
        <body><span id="blank">\xa3</span></body></html>'''
        x = self.sscls(text=text)
>       self.assertEquals(x.xpath("//span[@id='blank']/text()").extract(),
                          [u'\xa3'])
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertEquals'

tests/test_selector.py:571: AttributeError
_____________________ SelectorTestCase.test_invalid_xpath ______________________

self = <test_selector.SelectorTestCase testMethod=test_invalid_xpath>

    def test_invalid_xpath(self):
        "Test invalid xpath raises ValueError with the invalid xpath"
        x = self.sscls(text=u"<html></html>")
        xpath = "//test[@foo='bar]"
>       self.assertRaisesRegexp(ValueError, re.escape(xpath), x.xpath, xpath)
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertRaisesRegexp'

tests/test_selector.py:553: AttributeError
_________________ SelectorTestCase.test_invalid_xpath_unicode __________________

self = <test_selector.SelectorTestCase testMethod=test_invalid_xpath_unicode>

    def test_invalid_xpath_unicode(self):
        "Test *Unicode* invalid xpath raises ValueError with the invalid xpath"
        x = self.sscls(text=u"<html></html>")
        xpath = u"//test[@foo='\u0431ar]"
        encoded = xpath if six.PY3 else xpath.encode('unicode_escape')
>       self.assertRaisesRegexp(ValueError, re.escape(encoded), x.xpath, xpath)
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertRaisesRegexp'

tests/test_selector.py:560: AttributeError
________ SelectorTestCase.test_replacement_char_from_badly_encoded_body ________

self = <test_selector.SelectorTestCase testMethod=test_replacement_char_from_badly_encoded_body>

    def test_replacement_char_from_badly_encoded_body(self):
        # \xe9 alone isn't valid utf8 sequence
        text = u'<html><p>an Jos\ufffd de</p><html>'
>       self.assertEquals([u'an Jos\ufffd de'],
                          self.sscls(text).xpath('//text()').extract())
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertEquals'

tests/test_selector.py:588: AttributeError
__________________ SelectorTestCase.test_select_on_text_nodes __________________

self = <test_selector.SelectorTestCase testMethod=test_select_on_text_nodes>

    def test_select_on_text_nodes(self):
        r = self.sscls(text=u'<div><b>Options:</b>opt1</div><div><b>Other</b>opt2</div>')
        x1 = r.xpath("//div/descendant::text()[preceding-sibling::b[contains(text(), 'Options')]]")
>       self.assertEquals(x1.extract(), [u'opt1'])
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertEquals'

tests/test_selector.py:605: AttributeError
______________ SelectorTestCase.test_select_on_unevaluable_nodes _______________

self = <test_selector.SelectorTestCase testMethod=test_select_on_unevaluable_nodes>

    def test_select_on_unevaluable_nodes(self):
        r = self.sscls(text=u'<span class="big">some text</span>')
        # Text node
        x1 = r.xpath('//text()')
>       self.assertEquals(x1.extract(), [u'some text'])
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertEquals'

tests/test_selector.py:595: AttributeError
________________ SelectorTestCase.test_text_or_root_is_required ________________

self = <test_selector.SelectorTestCase testMethod=test_text_or_root_is_required>

    def test_text_or_root_is_required(self):
>       self.assertRaisesRegexp(ValueError,
                                'Selector needs either text or root argument',
                                self.sscls)
E       AttributeError: 'SelectorTestCase' object has no attribute 'assertRaisesRegexp'

tests/test_selector.py:271: AttributeError
___________ XPathFuncsTestCase.test_has_class_error_invalid_arg_type ___________

self = <test_xpathfuncs.XPathFuncsTestCase testMethod=test_has_class_error_invalid_arg_type>

    def test_has_class_error_invalid_arg_type(self):
        body = u"""
        <p CLASS="foo">First</p>
        """
        sel = Selector(text=body)
>       self.assertRaisesRegexp(
            ValueError, 'has-class arguments must be strings',
            sel.xpath, 'has-class(.)')
E       AttributeError: 'XPathFuncsTestCase' object has no attribute 'assertRaisesRegexp'

tests/test_xpathfuncs.py:44: AttributeError
___________ XPathFuncsTestCase.test_has_class_error_invalid_unicode ____________

self = <test_xpathfuncs.XPathFuncsTestCase testMethod=test_has_class_error_invalid_unicode>

    def test_has_class_error_invalid_unicode(self):
        body = u"""
        <p CLASS="foo">First</p>
        """
        sel = Selector(text=body)
>       self.assertRaisesRegexp(
            ValueError, 'All strings must be XML compatible',
            sel.xpath, u'has-class("héllö")'.encode('utf-8'))
E       AttributeError: 'XPathFuncsTestCase' object has no attribute 'assertRaisesRegexp'

tests/test_xpathfuncs.py:53: AttributeError
_______________ XPathFuncsTestCase.test_has_class_error_no_args ________________

self = <test_xpathfuncs.XPathFuncsTestCase testMethod=test_has_class_error_no_args>

    def test_has_class_error_no_args(self):
        body = u"""
        <p CLASS="foo">First</p>
        """
        sel = Selector(text=body)
>       self.assertRaisesRegexp(
            ValueError, 'has-class must have at least 1 argument',
            sel.xpath, 'has-class()')
E       AttributeError: 'XPathFuncsTestCase' object has no attribute 'assertRaisesRegexp'

tests/test_xpathfuncs.py:35: AttributeError
____________________ XPathFuncsTestCase.test_set_xpathfunc _____________________

self = <test_xpathfuncs.XPathFuncsTestCase testMethod=test_set_xpathfunc>

    def test_set_xpathfunc(self):
    
        def myfunc(ctx):
            myfunc.call_count += 1
    
        myfunc.call_count = 0
    
        body = u"""
        <p CLASS="foo">First</p>
        """
        sel = Selector(text=body)
>       self.assertRaisesRegexp(
            ValueError, 'Unregistered function in myfunc',
            sel.xpath, 'myfunc()')
E       AttributeError: 'XPathFuncsTestCase' object has no attribute 'assertRaisesRegexp'

Removed many old deprecated unittest features:
    TestCase method aliases failUnlessEqual, failIfEqual, failUnless, failIf,
    failUnlessRaises, failUnlessAlmostEqual, failIfAlmostEqual (deprecated in
    Python 3.1), assertEquals, assertNotEquals, assert_, assertAlmostEquals,
    assertNotAlmostEquals, assertRegexpMatches, assertRaisesRegexp (deprecated in
    Python 3.2), and assertNotRegexpMatches (deprecated in Python 3.5).

https://bugs.python.org/issue45162
https://docs.python.org/3.11/whatsnew/3.11.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/03058884-python-parsel/

For all our attempts to build python-parsel with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/python-parsel/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.11:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Hugo van Kemenade 2022-01-10 16:48:19 UTC
assertEquals fixed upstream in https://github.com/scrapy/parsel/pull/125 (Oct 2018, released in 1.5.1) and assertRaisesRegexp 
 in https://github.com/scrapy/parsel/pull/221 (Jul 2020, not yet released).

Comment 2 Ben Cotton 2022-02-08 21:13:35 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 36 development cycle.
Changing version to 36.

Comment 3 Tomáš Hrnčiar 2022-02-10 14:17:51 UTC
Removal of unittest aliases was reverted in Python 3.11 and will be part of Python 3.12, so the above failure is not present anymore, thus I am closing this bugzilla. However, this will be needed next year though so I encourage you to communicate with the upstream about it.

Comment 4 Tomáš Hrnčiar 2022-02-10 14:18:24 UTC
Removal of unittest aliases was reverted in Python 3.11 and will be part of Python 3.12, so the above failure is not present anymore, thus I am closing this bugzilla. However, this will be needed next year though so I encourage you to communicate with the upstream about it.


Note You need to log in before you can comment on or make changes to this bug.