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:
parent
a3ce4a1542
commit
63fe135f44
@ -5,5 +5,5 @@ sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
|
|||||||
Flask
|
Flask
|
||||||
flask-restful
|
flask-restful
|
||||||
nose
|
nose
|
||||||
coverage < 3.99
|
coverage!=4.4,>=4.0 # Apache-2.0
|
||||||
webtest
|
webtest
|
||||||
|
8
tox.ini
8
tox.ini
@ -11,18 +11,16 @@ deps =
|
|||||||
-r test-requirements.txt
|
-r test-requirements.txt
|
||||||
commands =
|
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 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]
|
[testenv:coverage]
|
||||||
deps =
|
|
||||||
coverage < 3.99
|
|
||||||
setenv =
|
setenv =
|
||||||
COVERAGE_FILE=.coverage
|
COVERAGE_FILE=.coverage
|
||||||
commands =
|
commands =
|
||||||
{envbindir}/coverage erase
|
{envbindir}/coverage erase
|
||||||
{envbindir}/coverage combine
|
{envbindir}/coverage combine
|
||||||
{envbindir}/coverage xml wsme/*.py wsme/rest/*.py wsmeext/*.py
|
{envbindir}/coverage xml --include="wsme/*.py","wsme/rest/*.py","wsmeext/*.py" --omit "wsme/tests/*"
|
||||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/protocols/*.py wsmeext/*.py
|
{envbindir}/coverage report --show-missing --include="wsme/*.py","wsme/rest/*.py","wsmeext/*.py" --omit "wsme/tests/*"
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
whitelist_externals =
|
whitelist_externals =
|
||||||
|
@ -26,7 +26,10 @@ def wrapfunc(f):
|
|||||||
|
|
||||||
def getargspec(f):
|
def getargspec(f):
|
||||||
f = getattr(f, '_wsme_original_func', 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):
|
class FunctionArgument(object):
|
||||||
@ -121,7 +124,8 @@ class FunctionDefinition(object):
|
|||||||
self.extra_options = extra_options
|
self.extra_options = extra_options
|
||||||
|
|
||||||
def set_arg_types(self, argspec, arg_types):
|
def set_arg_types(self, argspec, arg_types):
|
||||||
args, varargs, keywords, defaults = argspec
|
args = argspec.args
|
||||||
|
defaults = argspec.defaults
|
||||||
if args[0] == 'self':
|
if args[0] == 'self':
|
||||||
args = args[1:]
|
args = args[1:]
|
||||||
arg_types = list(arg_types)
|
arg_types = list(arg_types)
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import absolute_import
|
|||||||
|
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
|
import six
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pecan
|
import pecan
|
||||||
@ -134,7 +135,11 @@ def wsexpose(*args, **kwargs):
|
|||||||
pecan_text_xml_decorate(callfunction)
|
pecan_text_xml_decorate(callfunction)
|
||||||
if 'json' in funcdef.rest_content_types:
|
if 'json' in funcdef.rest_content_types:
|
||||||
pecan_json_decorate(callfunction)
|
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
|
callfunction._wsme_definition = funcdef
|
||||||
return callfunction
|
return callfunction
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user