Skip to content
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

AttributeError: type object 'TestCase' has no attribute 'failUnless' with Python 3.12 #829

Closed
sebastic opened this issue Dec 19, 2023 · 1 comment · Fixed by #833
Closed

Comments

@sebastic
Copy link
Contributor

sebastic commented Dec 19, 2023

Context

The testsuite fails with Python 3.12:

============================= test session starts ==============================
platform linux -- Python 3.12.1, pytest-7.4.3, pluggy-1.3.0
rootdir: /build/mapproxy-2.0.0+dfsg/.pybuild/cpython3_3.12_mapproxy/build
configfile: pytest.ini
collected 920 items / 82 errors

==================================== ERRORS ====================================
___________________ ERROR collecting mapproxy/test/helper.py ___________________
/usr/lib/python3/dist-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/usr/lib/python3/dist-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3/dist-packages/_pytest/doctest.py:567: in collect
    module = import_path(
/usr/lib/python3/dist-packages/_pytest/pathlib.py:567: in import_path
    importlib.import_module(module_name)
/usr/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1387: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:935: in _load_unlocked
    ???
<frozen importlib._bootstrap_external>:994: in exec_module
    ???
<frozen importlib._bootstrap>:488: in _call_with_frames_removed
    ???
mapproxy/test/helper.py:26: in <module>
    from mapproxy.test import mocker
mapproxy/test/mocker.py:126: in <module>
    class MockerTestCase(unittest.TestCase):
mapproxy/test/mocker.py:456: in MockerTestCase
    assertTrue = unittest.TestCase.failUnless
E   AttributeError: type object 'TestCase' has no attribute 'failUnless'
___________________ ERROR collecting mapproxy/test/mocker.py ___________________
[...]

The alias was removed, see: https://docs.python.org/3/whatsnew/3.12.html#unittest-testcase-removed-aliases

Expected Behavior

No test failure

Actual Behavior

Test failure

Possible Fix

Use assertTrue().

Steps to Reproduce

  1. Run tests with Python 3.12

Context

Build the Debian package with Python 3.11 and Python 3.12.

Your Environment

  • Version used: 2.0.0
  • Environment name and version (e.g. Python 2.7.5 with mod_wsgi 4.5.9): Python 3.12
  • Server type and version: N/A
  • Operating System and version: Debian unstable
@ramunasd
Copy link
Contributor

I see tests pipeline is not enabled for python 3.12.
Can You submit PR with the fix and enabled python 3.12? @sebastic

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 a pull request may close this issue.

2 participants