Fix coverage and getargspec deprecation

This patch fixes the coverage reporting and addresses the deprecation
of inspect.getargspec in python 3.x.

Change-Id: I3573e81a2d3b52d55b16a7d0fa6bbb82fb18fc04
This commit is contained in:
Michael Johnson 2020-11-19 10:06:10 -08:00
parent a3ce4a1542
commit 63fe135f44
4 changed files with 16 additions and 9 deletions

View File

@ -5,5 +5,5 @@ sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
Flask
flask-restful
nose
coverage < 3.99
coverage!=4.4,>=4.0 # Apache-2.0
webtest

View File

@ -11,18 +11,16 @@ deps =
-r test-requirements.txt
commands =
{envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs}
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
{envbindir}/coverage report --show-missing --include="wsme/*.py","wsme/rest/*.py","wsmeext/*.py" --omit "wsme/tests/*"
[testenv:coverage]
deps =
coverage < 3.99
setenv =
COVERAGE_FILE=.coverage
commands =
{envbindir}/coverage erase
{envbindir}/coverage combine
{envbindir}/coverage xml wsme/*.py wsme/rest/*.py wsmeext/*.py
{envbindir}/coverage report --show-missing wsme/*.py wsme/protocols/*.py wsmeext/*.py
{envbindir}/coverage xml --include="wsme/*.py","wsme/rest/*.py","wsmeext/*.py" --omit "wsme/tests/*"
{envbindir}/coverage report --show-missing --include="wsme/*.py","wsme/rest/*.py","wsmeext/*.py" --omit "wsme/tests/*"
[testenv:docs]
whitelist_externals =

View File

@ -26,7 +26,10 @@ def wrapfunc(f):
def getargspec(f):
f = getattr(f, '_wsme_original_func', f)
return inspect.getargspec(f)
if six.PY2:
return inspect.getargspec(f)
else:
return inspect.getfullargspec(f)
class FunctionArgument(object):
@ -121,7 +124,8 @@ class FunctionDefinition(object):
self.extra_options = extra_options
def set_arg_types(self, argspec, arg_types):
args, varargs, keywords, defaults = argspec
args = argspec.args
defaults = argspec.defaults
if args[0] == 'self':
args = args[1:]
arg_types = list(arg_types)

View File

@ -2,6 +2,7 @@ from __future__ import absolute_import
import functools
import inspect
import six
import sys
import pecan
@ -134,7 +135,11 @@ def wsexpose(*args, **kwargs):
pecan_text_xml_decorate(callfunction)
if 'json' in funcdef.rest_content_types:
pecan_json_decorate(callfunction)
pecan.util._cfg(callfunction)['argspec'] = inspect.getargspec(f)
if six.PY2:
argspec = inspect.getargspec(f)
else:
argspec = inspect.getfullargspec(f)
pecan.util._cfg(callfunction)['argspec'] = argspec
callfunction._wsme_definition = funcdef
return callfunction