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

Nose is incompatible with Python >= 3.10 #95

Closed
cclauss opened this issue Nov 8, 2021 · 8 comments · Fixed by #108
Closed

Nose is incompatible with Python >= 3.10 #95

cclauss opened this issue Nov 8, 2021 · 8 comments · Fixed by #108
Labels

Comments

@cclauss
Copy link
Contributor

cclauss commented Nov 8, 2021

nose.tools.assert_equals() will raise an AttributeError on Python >= 3.10

#93 used https://pypi.org/project/nose2pytest to migrate to pytest.

https://pypi.org/project/nose was last updated in 2015.

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.0/x64/bin/nosetests", line 8, in <module>
    sys.exit(run_exit())
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/site-packages/nose/core.py", line 118, in __init__
    unittest.TestProgram.__init__(
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/unittest/main.py", line 100, in __init__
    self.parseArgs(argv)
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/site-packages/nose/core.py", line 179, in parseArgs
    self.createTests()
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/site-packages/nose/core.py", line 193, in createTests
    self.test = self.testLoader.loadTestsFromNames(self.testNames)
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/site-packages/nose/loader.py", line 481, in loadTestsFromNames
    return unittest.TestLoader.loadTestsFromNames(self, names, module)
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/unittest/loader.py", line 220, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/unittest/loader.py", line 220, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/site-packages/nose/loader.py", line 454, in loadTestsFromName
    return LazySuite(
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/site-packages/nose/suite.py", line 53, in __init__
    super(LazySuite, self).__init__()
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/unittest/suite.py", line 22, in __init__
    self._tests = []
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/site-packages/nose/suite.py", line 106, in _set_tests
    if isinstance(tests, collections.Callable) and not is_suite:
AttributeError: module 'collections' has no attribute 'Callable'
@xlcnd
Copy link
Owner

xlcnd commented Nov 8, 2021

Thanks.

It's in my todo list to change to pytest, however I had to find the time to reconfigure my local dev env first! This applies to isbntools too.

@xlcnd
Copy link
Owner

xlcnd commented Sep 5, 2022

Anyway, the library can be used with python 3.10!

@cclauss
Copy link
Contributor Author

cclauss commented Sep 6, 2022

@xlcnd xlcnd closed this as completed in #108 Sep 9, 2022
@Pranavkhade
Copy link

Pranavkhade commented Mar 28, 2023

STATUS: RESOLVED

SOLUTION: Installing 'nose2' instead of the 'nosetests'

I am still having this issue; nosetest runs fine for 3.7, 3.8, and 3.9 but fails for 3.10.

Repo: https://github.com/Pranavkhade/PACKMAN
Command: nosetest packman

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.10/x64/bin/nosetests", line [8](https://github.com/Pranavkhade/PACKMAN/actions/runs/4538327140/jobs/7997128803#step:5:9), in <module>
    sys.exit(run_exit())
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/nose/core.py", line 118, in __init__
    unittest.TestProgram.__init__(
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/unittest/main.py", line 100, in __init__
    self.parseArgs(argv)
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/nose/core.py", line 17[9](https://github.com/Pranavkhade/PACKMAN/actions/runs/4538327140/jobs/7997128803#step:5:10), in parseArgs
    self.createTests()
  File "/opt/hostedtoolcache/Python/3.[10](https://github.com/Pranavkhade/PACKMAN/actions/runs/4538327140/jobs/7997128803#step:5:11).10/x64/lib/python3.10/site-packages/nose/core.py", line 193, in createTests
    self.test = self.testLoader.loadTestsFromNames(self.testNames)
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/nose/loader.py", line 481, in loadTestsFromNames
    return unittest.TestLoader.loadTestsFromNames(self, names, module)
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/unittest/loader.py", line 220, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/unittest/loader.py", line 220, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/nose/loader.py", line 431, in loadTestsFromName
    return self.loadTestsFromModule(
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/nose/loader.py", line 329, in loadTestsFromModule
    elif isfunction(test) and self.selector.wantFunction(test):
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/nose/selector.py", line [14](https://github.com/Pranavkhade/PACKMAN/actions/runs/4538327140/jobs/7997128803#step:5:15)9, in wantFunction
    plug_wants = self.plugins.wantFunction(function)
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/nose/plugins/manager.py", line 99, in __call__
    return self.call(*arg, **kw)
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/nose/plugins/manager.py", line [16](https://github.com/Pranavkhade/PACKMAN/actions/runs/4538327140/jobs/7997128803#step:5:17)7, in simple
    result = meth(*arg, **kw)
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/nose/plugins/attrib.py", line 278, in wantFunction
    return self.validateAttrib(function)
  File "/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/nose/plugins/attrib.py", line [24](https://github.com/Pranavkhade/PACKMAN/actions/runs/4538327140/jobs/7997128803#step:5:25)2, in validateAttrib
    if isinstance(value, collections.Callable):
AttributeError: module 'collections' has no attribute 'Callable'
Error: Process completed with exit code 1.

@cclauss
Copy link
Contributor Author

cclauss commented Mar 28, 2023

We ran https://pypi.org/project/nose2pytest in pull request #108 so now this repo tests with pytest, not nose.

@Sgrgeto
Copy link

Sgrgeto commented Apr 20, 2023

To run nose in python is this the proble is that module colleciton doesnt have the attribute Callable
You should change the lines of code 541 and 458 in the suite.py file. The correct line to run nose is this
you should change it also on the line 30 of the case.py file
if isinstance(tests, collections.abc.Callable) or isinstance(tests, unittest.TestSuite):
instead of
if isinstance(tests, collections.Callable) or isinstance(tests, unittest.TestSuite):

File "C:\Users\USUARIO\AppData\Local\Programs\Python\Python311\Lib\site-packages\nose\core.py", line 62, in run
test(result)
File "C:\Users\USUARIO\AppData\Local\Programs\Python\Python311\Lib\site-packages\nose\suite.py", line 178, in call
return self.run(*arg, **kw)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USUARIO\AppData\Local\Programs\Python\Python311\Lib\site-packages\nose\suite.py", line 225, in run
test(orig)
File "C:\Users\USUARIO\AppData\Local\Programs\Python\Python311\Lib\site-packages\nose\suite.py", line 178, in call
return self.run(*arg, **kw)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USUARIO\AppData\Local\Programs\Python\Python311\Lib\site-packages\nose\suite.py", line 218, in run
for test in self._tests:
File "C:\Users\USUARIO\AppData\Local\Programs\Python\Python311\Lib\site-packages\nose\suite.py", line 377, in _get_wrapped_tests
yield Test(test,
^^^^^^^^^^
File "C:\Users\USUARIO\AppData\Local\Programs\Python\Python311\Lib\site-packages\nose\case.py", line 30, in init
if not isinstance(test, collections.Callable):
^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'Callable'
2023-04-20 (1)

@geraldlawrence
Copy link

geraldlawrence commented Apr 27, 2024

nose is nolonger supported by py3. You need to reinstall pynose as an alter.
I uninstalled nose, and installed pynose. Then nosetests runs perfectly.
pip install pynose
nosetests
result:

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK

python version -- 3.10
runs in virtual env.

@cclauss
Copy link
Contributor Author

cclauss commented Apr 27, 2024

Ran 0 tests in 0.000s

Running zero tests is probably not testing anything.

https://github.com/pytest-dev/nose2pytest

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

Successfully merging a pull request may close this issue.

5 participants