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

Python 3.11: cannot import name '_TextTestResult' from 'unittest.runner' #1116

Open
jwilk opened this issue Oct 15, 2021 · 2 comments
Open

Comments

@jwilk
Copy link

jwilk commented Oct 15, 2021

nose doesn't work with Python 3.11:

$ python3.11 -m nose
Traceback (most recent call last):
  File "/home/jwilk/.local/lib/python3.11/site-packages/nose/result.py", line 14, in <module>
    from unittest.runner import _TextTestResult
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name '_TextTestResult' from 'unittest.runner' (/usr/local/lib/python3.11/unittest/runner.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/runpy.py", line 146, in _get_module_details
    return _get_module_details(pkg_main_name, error)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
    ^^^^^^^^^^^^^^^^^^^^
  File "/home/jwilk/.local/lib/python3.11/site-packages/nose/__init__.py", line 1, in <module>
    from nose.core import collector, main, run, run_exit, runmodule
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jwilk/.local/lib/python3.11/site-packages/nose/core.py", line 15, in <module>
    from nose.result import TextTestResult
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jwilk/.local/lib/python3.11/site-packages/nose/result.py", line 16, in <module>
    from unittest import _TextTestResult
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name '_TextTestResult' from 'unittest' (/usr/local/lib/python3.11/unittest/__init__.py)

This seems to be caused by python/cpython@b0a6ede,
which removes the _TextTestResult = TextTestResult alias.

@mr-c
Copy link
Contributor

mr-c commented Nov 16, 2022

This Python 3.11 change was reverted python/cpython#30935 (though there are other challenges running nose on Python 3.11 )

@hugovk
Copy link

hugovk commented Nov 16, 2022

And has been removed again for Python 3.12 (due October 2023):

$ python3.12 --version
Python 3.12.0a2
$ python3.12 -m nose
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/nose/result.py", line 14, in <module>
    from unittest.runner import _TextTestResult
ImportError: cannot import name '_TextTestResult' from 'unittest.runner' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/unittest/runner.py). Did you mean: 'TextTestResult'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 148, in _get_module_details
  File "<frozen runpy>", line 112, in _get_module_details
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/nose/__init__.py", line 1, in <module>
    from nose.core import collector, main, run, run_exit, runmodule
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/nose/core.py", line 15, in <module>
    from nose.result import TextTestResult
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/nose/result.py", line 16, in <module>
    from unittest import _TextTestResult
ImportError: cannot import name '_TextTestResult' from 'unittest' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/unittest/__init__.py). Did you mean: 'TextTestResult'?

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

No branches or pull requests

3 participants