nose-devs / nose

nose is nicer testing for python
http://readthedocs.org/docs/nose/en/latest/
1.36k stars 397 forks source link

nosetests errors when encountering special module-level function with annotations #1095

Open znewman01 opened 4 years ago

znewman01 commented 4 years ago

Example:

def setup_module() -> None:
    pass

It happens for setup_module() and teardown_module() but not e.g. test_something().

To repro:

$ python --version; nosetests -V
Python 3.7.3
nosetests version 1.3.7
$ echo "def setup_module() -> None: pass" > nose_test.py
$ nosetests nose_test.py

which gives the following stacktrace (path information stripped):

ERROR: test suite for <module 'test.nose_test' from '/tmp/nose_test.py'>
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".../python3.7/site-packages/nose/suite.py", line 209, in run
    self.setUp()
  File ".../python3.7/site-packages/nose/suite.py", line 292, in setUp
    self.setupContext(ancestor)
  File ".../python3.7/site-packages/nose/suite.py", line 315, in setupContext
    try_run(context, names)
  File "../lib/python3.7/site-packages/nose/util.py", line 453, in try_run
    inspect.getargspec(func)
  File ".../lib/python3.7/inspect.py", line 1082, in getargspec
    raise ValueError("Function has keyword-only parameters or annotations"
ValueError: Function has keyword-only parameters or annotations, use getfullargspec() API which can support them

----------------------------------------------------------------------
Ran 0 tests in 0.001s

FAILED (errors=1)

Comes from nose.util:try_run. I'm not sure what I'd suggest doing about it while supporting Python 2.