xlcnd / isbnlib

python library to validate, clean, transform and get metadata of ISBN strings (for devs).
Other
229 stars 30 forks source link

Nose is incompatible with Python >= 3.10 #95

Closed cclauss closed 2 years ago

cclauss commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

Anyway, the library can be used with python 3.10!

cclauss commented 2 years ago

Fixed in

Pranavkhade commented 1 year ago

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 commented 1 year ago

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

Sgrgeto commented 1 year ago

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 commented 6 months ago

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 commented 6 months ago

Ran 0 tests in 0.000s

Running zero tests is probably not testing anything.

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