Bug 2028067 - future fails to build with Python 3.11: AttributeError: 'TestUtils' object has no attribute 'assertRaisesRegexp'
Summary: future fails to build with Python 3.11: AttributeError: 'TestUtils' object ha...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: future
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Antonio T. sagitter
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.11
TreeView+ depends on / blocked
 
Reported: 2021-12-01 12:33 UTC by Tomáš Hrnčiar
Modified: 2021-12-04 16:26 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-12-04 16:26:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch for Python 3.11 (3.13 KB, patch)
2021-12-04 13:31 UTC, Antonio T. sagitter
no flags Details | Diff
Patch for Python 3.11 (1.34 KB, patch)
2021-12-04 15:37 UTC, Antonio T. sagitter
no flags Details | Diff

Description Tomáš Hrnčiar 2021-12-01 12:33:50 UTC
future fails to build with Python 3.11.0a2.

=================================== FAILURES ===================================
____________________________ TestUtils.test_raise_ _____________________________

self = <test_future.test_utils.TestUtils testMethod=test_raise_>

    def test_raise_(self):
        def valuerror():
            try:
                raise ValueError("Apples!")
            except Exception as e:
                raise_(e)
    
        self.assertRaises(ValueError, valuerror)
    
        def with_value():
            raise_(IOError, "This is an error")
    
        self.assertRaises(IOError, with_value)
    
        try:
            with_value()
        except IOError as e:
            self.assertEqual(str(e), "This is an error")
    
        def with_traceback():
            try:
                raise ValueError("An error")
            except Exception as e:
                _, _, traceback = sys.exc_info()
                raise_(IOError, str(e), traceback)
    
        self.assertRaises(IOError, with_traceback)
    
        try:
            with_traceback()
        except IOError as e:
            self.assertEqual(str(e), "An error")
    
        class Timeout(BaseException):
            pass
    
        self.assertRaises(Timeout, raise_, Timeout)
        self.assertRaises(Timeout, raise_, Timeout())
    
        if PY3:
>           self.assertRaisesRegexp(
                TypeError, "class must derive from BaseException",
                raise_, int)
E           AttributeError: 'TestUtils' object has no attribute 'assertRaisesRegexp'

tests/test_future/test_utils.py:153: AttributeError
__________________ TestCause.test_single_exception_stacktrace __________________

self = <test_future.test_utils.TestCause testMethod=test_single_exception_stacktrace>

        def test_single_exception_stacktrace(self):
            expected = '''Traceback (most recent call last):
      File "/opt/python-future/tests/test_future/test_utils.py", line 328, in test_single_exception_stacktrace
        raise CustomException('ERROR')
    '''
            if PY2:
                expected += 'CustomException: ERROR\n'
            else:
                expected += 'test_future.test_utils.CustomException: ERROR\n'
    
            try:
>               raise CustomException('ERROR')
E               test_future.test_utils.CustomException: ERROR

tests/test_future/test_utils.py:352: CustomException

During handling of the above exception, another exception occurred:

self = <test_future.test_utils.TestCause testMethod=test_single_exception_stacktrace>

        def test_single_exception_stacktrace(self):
            expected = '''Traceback (most recent call last):
      File "/opt/python-future/tests/test_future/test_utils.py", line 328, in test_single_exception_stacktrace
        raise CustomException('ERROR')
    '''
            if PY2:
                expected += 'CustomException: ERROR\n'
            else:
                expected += 'test_future.test_utils.CustomException: ERROR\n'
    
            try:
                raise CustomException('ERROR')
            except:
                ret = re.sub(r'"[^"]*tests/test_future', '"/opt/python-future/tests/test_future', traceback.format_exc())
                ret = re.sub(r', line \d+,', ', line 328,', ret)
>               self.assertEqual(expected, ret)
E               AssertionError: 'Trac[173 chars]\')\ntest_future.test_utils.CustomException: ERROR\n' != 'Trac[173 chars]\')\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ntest_[38 chars]OR\n'
E                 Traceback (most recent call last):
E                   File "/opt/python-future/tests/test_future/test_utils.py", line 328, in test_single_exception_stacktrace
E                     raise CustomException('ERROR')
E               +     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E                 test_future.test_utils.CustomException: ERROR

tests/test_future/test_utils.py:356: AssertionError

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).
    Undocumented and broken TestCase method assertDictContainsSubset (deprecated in Python 3.2).
    Undocumented <unittest.TestLoader.loadTestsFromModule> TestLoader.loadTestsFromModule() parameter use_load_tests (deprecated and ignored since Python 3.2).
    An alias of the TextTestResult class: _TextTestResult (deprecated in Python 3.2).

(Contributed by Serhiy Storchaka in bpo-45162.)

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/02990367-future/

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

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 Antonio T. sagitter 2021-12-04 11:55:38 UTC
These fixes are too much complicated for my knowledges of Python.

Comment 2 Miro Hrončok 2021-12-04 12:03:08 UTC
AttributeError: 'TestUtils' object has no attribute 'assertRaisesRegexp'

That's from https://github.com/PythonCharmers/python-future/blob/v0.18.2/tests/test_future/test_utils.py#L153

The fix is to replace assertRaisesRegexp with assertRaisesRegex. That's it.



AssertionError: 'Trac[173 chars]\')\ntest_future.test_utils.CustomException: ERROR\n' != 'Trac[173 chars]\')\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ntest_[38 chars]OR\n'...

That is an unexpected ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in the exception message in https://github.com/PythonCharmers/python-future/blob/v0.18.2/tests/test_future/test_utils.py#L342-L349 -- exception messages in Python 3.11 were improved this way.

The test can be fixed by adding ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to the expected exception output if Python is 3.11+.

E.g. before this: https://github.com/PythonCharmers/python-future/blob/v0.18.2/tests/test_future/test_utils.py#L346

Add something like (untested):

        if sys.version_info >= (3, 11):
            expected += '    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n'

Comment 3 Antonio T. sagitter 2021-12-04 13:21:34 UTC
(In reply to Miro Hrončok from comment #2)
> AttributeError: 'TestUtils' object has no attribute 'assertRaisesRegexp'
> 
> That's from
> https://github.com/PythonCharmers/python-future/blob/v0.18.2/tests/
> test_future/test_utils.py#L153
> 
> The fix is to replace assertRaisesRegexp with assertRaisesRegex. That's it.

I foresaw but not the following..

> 
> 
> 
> AssertionError: 'Trac[173 chars]\')\ntest_future.test_utils.CustomException:
> ERROR\n' != 'Trac[173 chars]\')\n   
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ntest_[38 chars]OR\n'...
> 
> That is an unexpected ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in the exception
> message in
> https://github.com/PythonCharmers/python-future/blob/v0.18.2/tests/
> test_future/test_utils.py#L342-L349 -- exception messages in Python 3.11
> were improved this way.
> 
> The test can be fixed by adding ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to the
> expected exception output if Python is 3.11+.
> 
> E.g. before this:
> https://github.com/PythonCharmers/python-future/blob/v0.18.2/tests/
> test_future/test_utils.py#L346
> 
> Add something like (untested):
> 
>         if sys.version_info >= (3, 11):
>             expected += '    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n'

I'll try.

Comment 4 Antonio T. sagitter 2021-12-04 13:31:57 UTC
Created attachment 1844697 [details]
Patch for Python 3.11

Comment 5 Antonio T. sagitter 2021-12-04 13:32:40 UTC
Output by using attached patch.

+ py.test-3.11 -k 'not test_pow and not test_urllib2'
============================= test session starts ==============================
platform linux -- Python 3.11.0a2, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /builddir/build/BUILD/future-0.18.2/python3, configfile: pytest.ini
collected 1129 items / 57 deselected / 1072 selected

tests/test_future/test_backports.py .................................... [  3%]
                                                                         [  3%]
tests/test_future/test_buffer.py ...................                     [  5%]
tests/test_future/test_builtins.py ........s...........s................ [  8%]
....sss..............s............                                       [ 11%]
tests/test_future/test_bytes.py ....................s..................x [ 15%]
........s...............                                                 [ 17%]
tests/test_future/test_chainmap.py ............                          [ 18%]
tests/test_future/test_common_iterators.py ....                          [ 19%]
tests/test_future/test_decorators.py ..                                  [ 19%]
tests/test_future/test_dict.py ..............                            [ 20%]
tests/test_future/test_email_multipart.py ..                             [ 20%]
tests/test_future/test_explicit_imports.py ..                            [ 21%]
tests/test_future/test_futurize.py ........s...x...x..x..x.......s.xsss. [ 24%]
x....x...x.....x.....x.xx.                                               [ 26%]
tests/test_future/test_html.py .                                         [ 27%]
tests/test_future/test_htmlparser.py ................................... [ 30%]
.......ss..........................                                      [ 33%]
tests/test_future/test_http_cookiejar.py ............................... [ 36%]
............................                                             [ 39%]
tests/test_future/test_httplib.py ...............s..............         [ 41%]
tests/test_future/test_import_star.py ......                             [ 42%]
tests/test_future/test_imports_httplib.py .                              [ 42%]
tests/test_future/test_imports_urllib.py ..                              [ 42%]
tests/test_future/test_int.py ...................x.........s             [ 45%]
tests/test_future/test_int_old_division.py ssss                          [ 45%]
tests/test_future/test_isinstance.py ................                    [ 47%]
tests/test_future/test_libfuturize_fixers.py ........................... [ 49%]
........                                                                 [ 50%]
tests/test_future/test_list.py ....................                      [ 52%]
tests/test_future/test_magicsuper.py ..s.s...                            [ 53%]
tests/test_future/test_object.py ..............                          [ 54%]
tests/test_future/test_pasteurize.py ..x...x...xx                        [ 55%]
tests/test_future/test_range.py ........................                 [ 57%]
tests/test_future/test_requests.py ss                                    [ 58%]
tests/test_future/test_standard_library.py ..........s....ss............ [ 60%]
.s.....ss...                                                             [ 61%]
tests/test_future/test_str.py .................s........................ [ 65%]
....s..x.                                                                [ 66%]
tests/test_future/test_super.py ...............                          [ 68%]
tests/test_future/test_surrogateescape.py ..........                     [ 69%]
tests/test_future/test_urllib.py ....................................... [ 72%]
........................s................                                [ 76%]
tests/test_future/test_urllib_response.py .                              [ 76%]
tests/test_future/test_urllib_toplevel.py .................s.....s..s... [ 79%]
.................................s.F..............                       [ 84%]
tests/test_future/test_urllibnet.py s.sssssssssss.                       [ 85%]
tests/test_future/test_urlparse.py .................................     [ 88%]
tests/test_future/test_utils.py ...................                      [ 90%]
tests/test_past/test_basestring.py .                                     [ 90%]
tests/test_past/test_builtins.py ...x..xxxxxx...x.xxxxxx....xx..xx..x.xx [ 93%]
.xx...x....x...x.                                                        [ 95%]
tests/test_past/test_noniterators.py .                                   [ 95%]
tests/test_past/test_olddict.py .....................s............       [ 98%]
tests/test_past/test_oldstr.py ....                                      [ 99%]
tests/test_past/test_translation.py ....x....                            [100%]

=================================== FAILURES ===================================
________________________ Utility_Tests.test_splitpasswd ________________________

self = <test_future.test_urllib_toplevel.Utility_Tests testMethod=test_splitpasswd>

    def test_splitpasswd(self):
        """Some of password examples are not sensible, but it is added to
        confirming to RFC2617 and addressing issue4675.
        """
>       self.assertEqual(('user', 'ab'),urllib_parse.urlparse('user:ab'))
E       AssertionError: ('user', 'ab') != ParseResult(scheme='user', netloc='', pat[36 chars]t='')

tests/test_future/test_urllib_toplevel.py:1206: AssertionError
=============================== warnings summary ===============================
build/lib/future/standard_library/__init__.py:65
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/standard_library/__init__.py:65: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
    import imp

tests/test_future/test_builtins.py:267
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_builtins.py:267: DeprecationWarning: invalid escape sequence '\u'
    (str(b'\u0663\u0661\u0664 ','raw-unicode-escape'), 314),

tests/test_future/test_builtins.py:289
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_builtins.py:289: DeprecationWarning: invalid escape sequence '\u'
    (str(b'\u0663\u0661\u0664 ','raw-unicode-escape'), 314),

build/lib/future/backports/test/support.py:1977
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/test/support.py:1977: DeprecationWarning: invalid escape sequence '\d'
    m = re.match("2.6.(\d{1,2})", kernel_version)

<unknown>:267
<unknown>:267
<unknown>:267
<unknown>:267
<unknown>:267
  <unknown>:267: DeprecationWarning: invalid escape sequence '\u'

<unknown>:289
<unknown>:289
<unknown>:289
<unknown>:289
<unknown>:289
  <unknown>:289: DeprecationWarning: invalid escape sequence '\u'

build/lib/future/backports/email/utils.py:68
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/email/utils.py:68: DeprecationWarning: invalid escape sequence '\A'
    '([^\ud800-\udbff]|\A)[\udc00-\udfff]([^\udc00-\udfff]|\Z)').search

build/lib/future/backports/urllib/parse.py:957
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/urllib/parse.py:957: DeprecationWarning: invalid escape sequence '\?'
    _queryprog = re.compile('^(.*)\?([^?]*)$')

build/lib/libfuturize/fixer_util.py:11
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/libfuturize/fixer_util.py:11: DeprecationWarning: lib2to3 package is deprecated and may not be able to parse Python 3.10+
    from lib2to3.fixer_util import (FromImport, Newline, is_import,

tests/test_future/test_htmlparser.py:685
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_htmlparser.py:685: DeprecationWarning: invalid escape sequence '\='
    "<a $><b $=%><c \=/>",

build/lib/future/backports/html/parser.py:31
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/html/parser.py:31: DeprecationWarning: invalid escape sequence '\s'
    tagfind = re.compile('([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*')

build/lib/future/backports/html/parser.py:79
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/html/parser.py:79: DeprecationWarning: invalid escape sequence '\s'
    endtagfind = re.compile('</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>')

<unknown>:685
<unknown>:685
<unknown>:685
<unknown>:685
<unknown>:685
  <unknown>:685: DeprecationWarning: invalid escape sequence '\='

tests/test_future/test_http_cookiejar.py:1034
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_http_cookiejar.py:1034: DeprecationWarning: invalid escape sequence '\$'
    self.assertRegex(h, "\$Port([^=]|$)",

tests/test_future/test_http_cookiejar.py:1373
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_http_cookiejar.py:1373: DeprecationWarning: invalid escape sequence '\s'
    '\s*\$Path="\/acme"')

tests/test_future/test_http_cookiejar.py:1375
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_http_cookiejar.py:1375: DeprecationWarning: invalid escape sequence '\s'
    '\s*\$Path="\/acme"')

build/lib/future/backports/http/client.py:1
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/http/client.py:1: DeprecationWarning: invalid escape sequence '\_'
    """HTTP/1.1 client library

build/lib/future/backports/email/feedparser.py:37
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/email/feedparser.py:37: DeprecationWarning: invalid escape sequence '\Z'
    NLCRE_eol = re.compile('(\r\n|\r|\n)\Z')

build/lib/future/backports/http/cookiejar.py:212
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/http/cookiejar.py:212: DeprecationWarning: invalid escape sequence '\d'
    "(\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$", re.ASCII)

build/lib/future/backports/http/cookiejar.py:289
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/http/cookiejar.py:289: DeprecationWarning: invalid escape sequence '\d'
    """^

build/lib/future/backports/http/cookiejar.py:423
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/http/cookiejar.py:423: DeprecationWarning: invalid escape sequence '\s'
    non_junk, nr_junk_chars = re.subn("^[=\s;]*", "", text)

<unknown>:1034
<unknown>:1034
<unknown>:1034
<unknown>:1034
<unknown>:1034
  <unknown>:1034: DeprecationWarning: invalid escape sequence '\$'

<unknown>:1373
<unknown>:1373
<unknown>:1373
<unknown>:1373
<unknown>:1373
  <unknown>:1373: DeprecationWarning: invalid escape sequence '\s'

<unknown>:1375
<unknown>:1375
<unknown>:1375
<unknown>:1375
<unknown>:1375
  <unknown>:1375: DeprecationWarning: invalid escape sequence '\s'

tests/test_future/test_urllib.py:536
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_urllib.py:536: DeprecationWarning: invalid escape sequence '\^'
    """Tests for urllib.quote() and urllib.quote_plus()

tests/test_future/test_urllib.py:611
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_urllib.py:611: DeprecationWarning: invalid escape sequence '\^'
    should_quote.append('<>#%"{}|\^[]`')

<unknown>:536: 14 warnings
  <unknown>:536: DeprecationWarning: invalid escape sequence '\^'

<unknown>:611: 14 warnings
  <unknown>:611: DeprecationWarning: invalid escape sequence '\^'

tests/test_future/test_urllib_toplevel.py:551
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_urllib_toplevel.py:551: DeprecationWarning: invalid escape sequence '\^'
    """Tests for urllib.quote() and urllib.quote_plus()

tests/test_future/test_urllib_toplevel.py:626
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_urllib_toplevel.py:626: DeprecationWarning: invalid escape sequence '\^'
    should_quote.append('<>#%"{}|\^[]`')

<unknown>:551: 14 warnings
  <unknown>:551: DeprecationWarning: invalid escape sequence '\^'

<unknown>:626: 14 warnings
  <unknown>:626: DeprecationWarning: invalid escape sequence '\^'

build/lib/past/types/oldstr.py:23
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/past/types/oldstr.py:23: DeprecationWarning: invalid escape sequence '\d'
    """

tests/test_future/test_htmlparser.py: 4 warnings
tests/test_future/test_http_cookiejar.py: 5 warnings
tests/test_future/test_urllibnet.py: 3 warnings
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/test/support.py:1656: DeprecationWarning: unittest.makeSuite() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromTestCase() instead.
    suite.addTest(unittest.makeSuite(cls))

tests/test_future/test_httplib.py::SourceAddressTest::testHTTPSConnectionSourceAddress
tests/test_future/test_httplib.py::HTTPSTest::test_attributes
tests/test_future/test_httplib.py::HTTPSTest::test_host_port
tests/test_future/test_httplib.py::HTTPSTest::test_host_port
tests/test_future/test_httplib.py::HTTPSTest::test_host_port
tests/test_future/test_httplib.py::HTTPSTest::test_host_port
tests/test_future/test_httplib.py::HTTPSTest::test_host_port
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/future/backports/http/client.py:1218: DeprecationWarning: ssl.PROTOCOL_TLS is deprecated
    context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)

tests/test_future/test_standard_library.py::TestStandardLibraryReorganization::test_reload
  /usr/lib64/python3.11/importlib/__init__.py:169: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
    _bootstrap._exec(spec, module)

tests/test_future/test_urllibnet.py::urlopenNetworkTests::test_getcode
tests/test_future/test_urllibnet.py::test_main
  /builddir/build/BUILD/future-0.18.2/python3/tests/test_future/test_urllibnet.py:103: DeprecationWarning: FancyURLopener style of invoking requests is deprecated. Use newer urlopen functions/methods
    open_url = urllib_request.FancyURLopener().open(URL)

tests/test_past/test_oldstr.py::TestOldStr::test_unescape
  /builddir/build/BUILD/future-0.18.2/python3/build/lib/past/types/oldstr.py:37: DeprecationWarning: invalid escape sequence '\c'
    return s.encode().decode('unicode_escape')

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED tests/test_future/test_urllib_toplevel.py::Utility_Tests::test_splitpasswd
= 1 failed, 974 passed, 51 skipped, 57 deselected, 46 xfailed, 132 warnings in 12.08s =

Comment 6 Miro Hrončok 2021-12-04 14:12:12 UTC
That is caused by the patch directly:

--- a/tests/test_future/test_urllib_toplevel.orig.py	2021-12-04 12:16:44.475424000 +0100
+++ b/tests/test_future/test_urllib_toplevel.py	2021-12-04 12:37:15.282519570 +0100
@@ -1203,16 +1203,16 @@
         """Some of password examples are not sensible, but it is added to
         confirming to RFC2617 and addressing issue4675.
         """
-        self.assertEqual(('user', 'ab'),urllib_parse.splitpasswd('user:ab'))
-        self.assertEqual(('user', 'a\nb'),urllib_parse.splitpasswd('user:a\nb'))
-        self.assertEqual(('user', 'a\tb'),urllib_parse.splitpasswd('user:a\tb'))
-        self.assertEqual(('user', 'a\rb'),urllib_parse.splitpasswd('user:a\rb'))
-        self.assertEqual(('user', 'a\fb'),urllib_parse.splitpasswd('user:a\fb'))
-        self.assertEqual(('user', 'a\vb'),urllib_parse.splitpasswd('user:a\vb'))
-        self.assertEqual(('user', 'a:b'),urllib_parse.splitpasswd('user:a:b'))
-        self.assertEqual(('user', 'a b'),urllib_parse.splitpasswd('user:a b'))
-        self.assertEqual(('user 2', 'ab'),urllib_parse.splitpasswd('user 2:ab'))
-        self.assertEqual(('user+1', 'a+b'),urllib_parse.splitpasswd('user+1:a+b'))
+        self.assertEqual(('user', 'ab'),urllib_parse.urlparse('user:ab'))
+        self.assertEqual(('user', 'a\nb'),urllib_parse.urlparse('user:a\nb'))
+        self.assertEqual(('user', 'a\tb'),urllib_parse.urlparse('user:a\tb'))
+        self.assertEqual(('user', 'a\rb'),urllib_parse.urlparse('user:a\rb'))
+        self.assertEqual(('user', 'a\fb'),urllib_parse.urlparse('user:a\fb'))
+        self.assertEqual(('user', 'a\vb'),urllib_parse.urlparse('user:a\vb'))
+        self.assertEqual(('user', 'a:b'),urllib_parse.urlparse('user:a:b'))
+        self.assertEqual(('user', 'a b'),urllib_parse.urlparse('user:a b'))
+        self.assertEqual(('user 2', 'ab'),urllib_parse.urlparse('user 2:ab'))
+        self.assertEqual(('user+1', 'a+b'),urllib_parse.urlparse('user+1:a+b'))
 
The test is designed to test that splitpasswd() works, by replacing the calls directly with urlparse() calls:

 - the purpose of the test is defeated
 - the test fails, because this is not a drop-in replacement, but a replacement that returns a different structure


I don't know enough about this "future" library and whether install_aliases() should also patch Python 3 functions to be backwards compatible, but I suppose not. Hence I recommend skipping all splitpasswd tests on Python 3.11+ instead of patching it like this.

You can decorate it with:

    @unittest.skipIf(sys.version_info >= (3, 11), "urllib.parse.splitpasswd() was removed from Python 3.11+")
    def test_splitpasswd(self):
        ...

Comment 7 Antonio T. sagitter 2021-12-04 15:37:22 UTC
Created attachment 1844709 [details]
Patch for Python 3.11

I rebuilt this package with this patch.
Thank you Miro.


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