Skip to content

Adjust tests to the changes in Python 3.12 #619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

hrnciar
Copy link
Contributor

@hrnciar hrnciar commented May 17, 2023

Fixes: #618

@sagitter
Copy link

Thank you @hrnciar

Two tests are still failing with Python-3.11:

+ cd python-future-0.18.3
+ PYTHONPATH=/builddir/build/BUILD/python-future-0.18.3/build/lib
+ py.test-3.11 -k 'not test_urllibnet and not test_single_exception_stacktrace' -q
..............................FF........................................ [  6%]
...s....................sss..............s.............................. [ 12%]
...s..................x........s........................................ [ 19%]
......................s...x...x..x..x.......s.xsss.x....x...x.....x..... [ 25%]
x.xx............................................ss...................... [ 31%]
........................................................................ [ 38%]
......s..........................................x.........sssss........ [ 44%]
........................................................................ [ 51%]
s.s...................x...x...xx........................ss..........s... [ 57%]
.ss.............s.....ss....................s........................... [ 63%]
.s..x................................................................... [ 70%]
.......................s.............................................s.. [ 76%]
.........................................s.....s..s..................... [ 83%]
...............s.s...................................................... [ 89%]
................x..xxxxxx...x.xxxxxx....xx..xx..x.xx.xxx...x....x...x... [ 95%]
.....................s....................x....                          [100%]
=================================== FAILURES ===================================
__________________________ TestOrderedDict.test_repr ___________________________
self = <test_future.test_backports.TestOrderedDict testMethod=test_repr>
    def test_repr(self):
        od = OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])
>       self.assertEqual(repr(od),
            "OrderedDict({'c': 1, 'b': 2, 'a': 3, 'd': 4, 'e': 5, 'f': 6})")
E       AssertionError: "OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])" != "OrderedDict({'c': 1, 'b': 2, 'a': 3, 'd': 4, 'e': 5, 'f': 6})"
E       - OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])
E       + OrderedDict({'c': 1, 'b': 2, 'a': 3, 'd': 4, 'e': 5, 'f': 6})
tests/test_future/test_backports.py:602: AssertionError
_____________________ TestOrderedDict.test_repr_recursive ______________________
self = <test_future.test_backports.TestOrderedDict testMethod=test_repr_recursive>
    def test_repr_recursive(self):
        # See issue #9826
        od = OrderedDict.fromkeys('abc')
        od['x'] = od
>       self.assertEqual(repr(od),
            "OrderedDict({'a': None, 'b': None, 'c': None, 'x': ...})")
E       AssertionError: "OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)])" != "OrderedDict({'a': None, 'b': None, 'c': None, 'x': ...})"
E       - OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)])
E       ?             ^^   ^     -  -   ^     -  -   ^     -  -   ^    ^^
E       + OrderedDict({'a': None, 'b': None, 'c': None, 'x': ...})
E       ?             ^   ^          ^          ^          ^    ^
tests/test_future/test_backports.py:611: AssertionError
=============================== warnings summary ===============================
build/lib/future/standard_library/__init__.py:65
  /builddir/build/BUILD/python-future-0.18.3/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:266
  /builddir/build/BUILD/python-future-0.18.3/tests/test_future/test_builtins.py:266: DeprecationWarning: invalid escape sequence '\u'
    (str(b'\u0663\u0661\u0664 ','raw-unicode-escape'), 314),
tests/test_future/test_builtins.py:288
  /builddir/build/BUILD/python-future-0.18.3/tests/test_future/test_builtins.py:288: 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/python-future-0.18.3/build/lib/future/backports/test/support.py:1977: DeprecationWarning: invalid escape sequence '\d'
    m = re.match("2.6.(\d{1,2})", kernel_version)
build/lib/future/backports/email/message.py:13
  /builddir/build/BUILD/python-future-0.18.3/build/lib/future/backports/email/message.py:13: DeprecationWarning: 'uu' is deprecated and slated for removal in Python 3.13
    import uu
build/lib/future/backports/email/utils.py:68
  /builddir/build/BUILD/python-future-0.18.3/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/python-future-0.18.3/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/python-future-0.18.3/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/python-future-0.18.3/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/python-future-0.18.3/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/python-future-0.18.3/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*>')
tests/test_future/test_http_cookiejar.py:1034
  /builddir/build/BUILD/python-future-0.18.3/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/python-future-0.18.3/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/python-future-0.18.3/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/python-future-0.18.3/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/python-future-0.18.3/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/python-future-0.18.3/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:293
  /builddir/build/BUILD/python-future-0.18.3/build/lib/future/backports/http/cookiejar.py:293: DeprecationWarning: invalid escape sequence '\d'
    """^
build/lib/future/backports/http/cookiejar.py:429
  /builddir/build/BUILD/python-future-0.18.3/build/lib/future/backports/http/cookiejar.py:429: DeprecationWarning: invalid escape sequence '\s'
    non_junk, nr_junk_chars = re.subn("^[=\s;]*", "", text)
tests/test_future/test_urllib.py:536
  /builddir/build/BUILD/python-future-0.18.3/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/python-future-0.18.3/tests/test_future/test_urllib.py:611: DeprecationWarning: invalid escape sequence '\^'
    should_quote.append('<>#%"{}|\^[]`')
tests/test_future/test_urllib_toplevel.py:551
  /builddir/build/BUILD/python-future-0.18.3/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/python-future-0.18.3/tests/test_future/test_urllib_toplevel.py:626: DeprecationWarning: invalid escape sequence '\^'
    should_quote.append('<>#%"{}|\^[]`')
tests/test_future/test_htmlparser.py: 4 warnings
tests/test_future/test_http_cookiejar.py: 5 warnings
tests/test_future/test_urllib2.py: 6 warnings
  /builddir/build/BUILD/python-future-0.18.3/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/python-future-0.18.3/build/lib/future/backports/http/client.py:1218: DeprecationWarning: ssl.PROTOCOL_TLS is deprecated
    context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
tests/test_future/test_int.py::IntTestCases::test_intconversion
tests/test_future/test_int.py::IntTestCases::test_intconversion
tests/test_future/test_int.py::IntTestCases::test_intconversion
tests/test_future/test_int.py::IntTestCases::test_intconversion
  /builddir/build/BUILD/python-future-0.18.3/tests/test_future/test_int.py:401: DeprecationWarning: The delegation of int() to __trunc__ is deprecated.
    int(TruncReturnsNonIntegral())
tests/test_future/test_int.py::IntTestCases::test_intconversion
tests/test_future/test_int.py::IntTestCases::test_intconversion
tests/test_future/test_int.py::IntTestCases::test_intconversion
tests/test_future/test_int.py::IntTestCases::test_intconversion
  /builddir/build/BUILD/python-future-0.18.3/tests/test_future/test_int.py:421: DeprecationWarning: The delegation of int() to __trunc__ is deprecated.
    int(TruncReturnsBadInt())
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_past/test_oldstr.py::TestOldStr::test_unescape
  /builddir/build/BUILD/python-future-0.18.3/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/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_future/test_backports.py::TestOrderedDict::test_repr - Asse...
FAILED tests/test_future/test_backports.py::TestOrderedDict::test_repr_recursive

@hrnciar
Copy link
Contributor Author

hrnciar commented May 18, 2023

I've added a condition to test changed repr only on Python 3.12+

@edschofield edschofield merged commit bcced95 into PythonCharmers:master Feb 21, 2024
@edschofield
Copy link
Contributor

Thanks @hrnciar !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changes in Python 3.12 break tests
3 participants