Bug 2028067
Summary: | future fails to build with Python 3.11: AttributeError: 'TestUtils' object has no attribute 'assertRaisesRegexp' | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Tomáš Hrnčiar <thrnciar> | ||||||
Component: | future | Assignee: | Antonio T. sagitter <trpost> | ||||||
Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||||
Severity: | unspecified | Docs Contact: | |||||||
Priority: | unspecified | ||||||||
Version: | rawhide | CC: | mhroncok, thrnciar, trpost | ||||||
Target Milestone: | --- | ||||||||
Target Release: | --- | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | Doc Type: | If docs needed, set a value | |||||||
Doc Text: | Story Points: | --- | |||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2021-12-04 16:26:44 UTC | Type: | Bug | ||||||
Regression: | --- | Mount Type: | --- | ||||||
Documentation: | --- | CRM: | |||||||
Verified Versions: | Category: | --- | |||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||
Embargoed: | |||||||||
Bug Depends On: | |||||||||
Bug Blocks: | 2016048 | ||||||||
Attachments: |
|
Description
Tomáš Hrnčiar
2021-12-01 12:33:50 UTC
These fixes are too much complicated for my knowledges of Python. 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' (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. Created attachment 1844697 [details]
Patch for Python 3.11
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 = 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): ... Created attachment 1844709 [details]
Patch for Python 3.11
I rebuilt this package with this patch.
Thank you Miro.
|