From ecaf3aa40f0fc09a30bf2e47b42bf4c4314c1dc0 Mon Sep 17 00:00:00 2001 From: Vladyslav Drok Date: Thu, 22 Dec 2016 14:56:42 +0200 Subject: [PATCH] Fix pep8 issues and switch to py35 in tox.ini This change also adds cornice-py3 environment to tox-tmpl.ini, as previously it was added manually directly in tox.ini. Change-Id: I6c0924ca4cc7a42b57af01312da21b94ed1efa85 --- tox-tmpl.ini | 27 +++++--- tox.ini | 103 +++++++++++++++--------------- wsme/api.py | 1 + wsme/tests/test_restjson.py | 1 + wsme/types.py | 3 + wsmeext/pecan.py | 1 + wsmeext/soap/wsdl.py | 1 + wsmeext/sqlalchemy/controllers.py | 1 + wsmeext/tests/test_soap.py | 4 ++ 9 files changed, 82 insertions(+), 60 deletions(-) diff --git a/tox-tmpl.ini b/tox-tmpl.ini index 2940bde..69502df 100644 --- a/tox-tmpl.ini +++ b/tox-tmpl.ini @@ -1,6 +1,6 @@ # content of: tox.ini , put in same dir as setup.py [tox] -envlist = py27,py27-nolxml,pypy,tg11,tg15,cornice,coverage,py34,py34-nolxml,pecan-dev27,pecan-dev34,pep8 +envlist = py27,py27-nolxml,pypy,tg11,tg15,cornice,cornice-py3,coverage,py35,py35-nolxml,pecan-dev27,pecan-dev35,pep8 [common] testtools= @@ -17,13 +17,13 @@ basedeps= flask-restful [axes] -python=py27,py34,pypy +python=py27,py35,pypy sqlalchemy=sa5,sa6,sa7* lxml=lxml*,nolxml json=json*,simplejson [axis:python] -deps = +deps = {[common]testtools} {[common]basedeps} suds-jurko @@ -36,8 +36,8 @@ commands= [axis:python:py27] basepython=python2.7 -[axis:python:py34] -basepython=python3.4 +[axis:python:py35] +basepython=python3.5 [axis:sqlalchemy:sa5] deps= @@ -76,6 +76,17 @@ commands= {envbindir}/nosetests tests/test_cornice.py --with-xunit --xunit-file nosetests-{envname}.xml --verbose --with-coverage --cover-package wsmeext {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsmeext/cornice.py +[testenv:cornice-py3] +basepython = python3.5 +usedevelop = {[testenv:cornice]usedevelop} +deps = {[testenv:cornice]deps} +# disable hash randomization +setenv = + PYTHONHASHSEED=0 +commands = + {envbindir}/nosetests tests/test_cornice.py --with-xunit --xunit-file nosetests-{envname}.xml --verbose --with-coverage --cover-package wsmeext {posargs} + {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsmeext/cornice.py + [testenv:pecan-dev-base] deps= {[common]testtools} @@ -89,8 +100,8 @@ deps={[testenv:pecan-dev-base]deps} commands= {envbindir}/nosetests tests/pecantest --with-xunit --xunit-file nosetests-{envname}.xml --verbose {posargs} -[testenv:pecan-dev34] -basepython=python3.4 +[testenv:pecan-dev35] +basepython=python3.5 deps={[testenv:pecan-dev-base]deps} commands= {envbindir}/nosetests tests/pecantest --with-xunit --xunit-file nosetests-{envname}.xml --verbose {posargs} @@ -127,6 +138,6 @@ commands = flake8 wsme wsmeext setup.py commands = {posargs} usedevelop=True deps = - pbr + pbr oslo.config oslotest diff --git a/tox.ini b/tox.ini index 33ffb66..dea7f76 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py27-nolxml,pypy,tg11,tg15,cornice,cornice-py3,coverage,py34,py34-nolxml,pecan-dev27,pecan-dev34,pep8 +envlist = py27,py27-nolxml,pypy,tg11,tg15,cornice,cornice-py3,coverage,py35,py35-nolxml,pecan-dev27,pecan-dev35,pep8 [common] testtools = @@ -33,13 +33,12 @@ commands = {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsmeext/cornice.py [testenv:cornice-py3] -basepython = python3 +basepython = python3.5 usedevelop = {[testenv:cornice]usedevelop} deps = {[testenv:cornice]deps} -# disable hash randomization -setenv = - PYTHONHASHSEED=0 -commands = +setenv = + PYTHONHASHSEED=0 +commands = {envbindir}/nosetests tests/test_cornice.py --with-xunit --xunit-file nosetests-{envname}.xml --verbose --with-coverage --cover-package wsmeext {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsmeext/cornice.py @@ -56,8 +55,8 @@ deps = {[testenv:pecan-dev-base]deps} commands = {envbindir}/nosetests tests/pecantest --with-xunit --xunit-file nosetests-{envname}.xml --verbose {posargs} -[testenv:pecan-dev34] -basepython = python3.4 +[testenv:pecan-dev35] +basepython = python3.5 deps = {[testenv:pecan-dev-base]deps} commands = {envbindir}/nosetests tests/pecantest --with-xunit --xunit-file nosetests-{envname}.xml --verbose {posargs} @@ -381,7 +380,7 @@ deps = simplejson basepython = python2.7 -[testenv:py34-sa5-lxml-json] +[testenv:py35-sa5-lxml-json] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -392,9 +391,9 @@ deps = suds-jurko SQLAlchemy<=0.5.99 lxml -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa5] +[testenv:py35-sa5] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -405,9 +404,9 @@ deps = suds-jurko SQLAlchemy<=0.5.99 lxml -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa5-lxml-simplejson] +[testenv:py35-sa5-lxml-simplejson] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -419,9 +418,9 @@ deps = SQLAlchemy<=0.5.99 lxml simplejson -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa5-simplejson] +[testenv:py35-sa5-simplejson] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -433,9 +432,9 @@ deps = SQLAlchemy<=0.5.99 lxml simplejson -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa5-nolxml-json] +[testenv:py35-sa5-nolxml-json] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -445,9 +444,9 @@ deps = {[common]basedeps} suds-jurko SQLAlchemy<=0.5.99 -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa5-nolxml] +[testenv:py35-sa5-nolxml] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -457,9 +456,9 @@ deps = {[common]basedeps} suds-jurko SQLAlchemy<=0.5.99 -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa5-nolxml-simplejson] +[testenv:py35-sa5-nolxml-simplejson] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -470,9 +469,9 @@ deps = suds-jurko SQLAlchemy<=0.5.99 simplejson -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa6-lxml-json] +[testenv:py35-sa6-lxml-json] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -483,9 +482,9 @@ deps = suds-jurko SQLAlchemy<=0.6.99 lxml -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa6] +[testenv:py35-sa6] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -496,9 +495,9 @@ deps = suds-jurko SQLAlchemy<=0.6.99 lxml -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa6-lxml-simplejson] +[testenv:py35-sa6-lxml-simplejson] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -510,9 +509,9 @@ deps = SQLAlchemy<=0.6.99 lxml simplejson -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa6-simplejson] +[testenv:py35-sa6-simplejson] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -524,9 +523,9 @@ deps = SQLAlchemy<=0.6.99 lxml simplejson -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa6-nolxml-json] +[testenv:py35-sa6-nolxml-json] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -536,9 +535,9 @@ deps = {[common]basedeps} suds-jurko SQLAlchemy<=0.6.99 -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa6-nolxml] +[testenv:py35-sa6-nolxml] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -548,9 +547,9 @@ deps = {[common]basedeps} suds-jurko SQLAlchemy<=0.6.99 -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa6-nolxml-simplejson] +[testenv:py35-sa6-nolxml-simplejson] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -561,9 +560,9 @@ deps = suds-jurko SQLAlchemy<=0.6.99 simplejson -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa7-lxml-json] +[testenv:py35-sa7-lxml-json] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -574,9 +573,9 @@ deps = suds-jurko SQLAlchemy<=0.7.99 lxml -basepython = python3.4 +basepython = python3.5 -[testenv:py34] +[testenv:py35] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -587,9 +586,9 @@ deps = suds-jurko SQLAlchemy<=0.7.99 lxml -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa7-lxml-simplejson] +[testenv:py35-sa7-lxml-simplejson] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -601,9 +600,9 @@ deps = SQLAlchemy<=0.7.99 lxml simplejson -basepython = python3.4 +basepython = python3.5 -[testenv:py34-simplejson] +[testenv:py35-simplejson] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -615,9 +614,9 @@ deps = SQLAlchemy<=0.7.99 lxml simplejson -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa7-nolxml-json] +[testenv:py35-sa7-nolxml-json] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -627,9 +626,9 @@ deps = {[common]basedeps} suds-jurko SQLAlchemy<=0.7.99 -basepython = python3.4 +basepython = python3.5 -[testenv:py34-nolxml] +[testenv:py35-nolxml] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -639,9 +638,9 @@ deps = {[common]basedeps} suds-jurko SQLAlchemy<=0.7.99 -basepython = python3.4 +basepython = python3.5 -[testenv:py34-sa7-nolxml-simplejson] +[testenv:py35-sa7-nolxml-simplejson] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -652,9 +651,9 @@ deps = suds-jurko SQLAlchemy<=0.7.99 simplejson -basepython = python3.4 +basepython = python3.5 -[testenv:py34-nolxml-simplejson] +[testenv:py35-nolxml-simplejson] commands = {envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py @@ -665,7 +664,7 @@ deps = suds-jurko SQLAlchemy<=0.7.99 simplejson -basepython = python3.4 +basepython = python3.5 [testenv:pypy-sa5-lxml-json] commands = diff --git a/wsme/api.py b/wsme/api.py index 4aab9a4..e5fe7c6 100644 --- a/wsme/api.py +++ b/wsme/api.py @@ -182,6 +182,7 @@ class signature(object): fd.set_arg_types(argspec, self.arg_types) return func + sig = signature diff --git a/wsme/tests/test_restjson.py b/wsme/tests/test_restjson.py index d7c8110..a764e86 100644 --- a/wsme/tests/test_restjson.py +++ b/wsme/tests/test_restjson.py @@ -148,6 +148,7 @@ class MiniCrud(object): ref.name = u('test') return CRUDResult(ref, u('delete')) + wsme.tests.protocol.WSTestRoot.crud = MiniCrud() diff --git a/wsme/types.py b/wsme/types.py index eca915c..0a5fc02 100644 --- a/wsme/types.py +++ b/wsme/types.py @@ -135,6 +135,7 @@ class BinaryType(UserType): return None return base64.decodestring(value) + #: The binary almost-native type binary = BinaryType() @@ -325,6 +326,7 @@ class UnsetType(object): def __repr__(self): return 'Unset' + Unset = UnsetType() #: A special type that corresponds to the host framework request object. @@ -741,6 +743,7 @@ class Registry(object): type_ = self.register(type_) return type_ + # Default type registry registry = Registry() diff --git a/wsmeext/pecan.py b/wsmeext/pecan.py index f1fa933..64aa3e6 100644 --- a/wsmeext/pecan.py +++ b/wsmeext/pecan.py @@ -43,6 +43,7 @@ class XMLRenderer(object): namespace['datatype'] ) + pecan.templating._builtin_renderers['wsmejson'] = JSonRenderer pecan.templating._builtin_renderers['wsmexml'] = XMLRenderer diff --git a/wsmeext/soap/wsdl.py b/wsmeext/soap/wsdl.py index fad0ad7..b60aff4 100644 --- a/wsmeext/soap/wsdl.py +++ b/wsmeext/soap/wsdl.py @@ -28,6 +28,7 @@ class NS(object): def qn(self, name): return '{%s}%s' % (self.url, name) + wsdl_ns = NS("http://schemas.xmlsoap.org/wsdl/") soap_ns = NS("http://schemas.xmlsoap.org/wsdl/soap/") xs_ns = NS("http://www.w3.org/2001/XMLSchema") diff --git a/wsmeext/sqlalchemy/controllers.py b/wsmeext/sqlalchemy/controllers.py index fe77bf4..504a46a 100644 --- a/wsmeext/sqlalchemy/controllers.py +++ b/wsmeext/sqlalchemy/controllers.py @@ -91,6 +91,7 @@ class CRUDControllerBase(object): self.__dbsession__.flush() return None + CRUDController = CRUDControllerMeta( 'CRUDController', (CRUDControllerBase,), {} ) diff --git a/wsmeext/tests/test_soap.py b/wsmeext/tests/test_soap.py index 845fd26..aa8f76d 100644 --- a/wsmeext/tests/test_soap.py +++ b/wsmeext/tests/test_soap.py @@ -28,6 +28,7 @@ class XDecimal(suds.xsd.sxbuiltin.XBuiltin): return str(value) return value + suds.xsd.sxbuiltin.Factory.tags['decimal'] = XDecimal @@ -83,6 +84,7 @@ class SudsCache(suds.cache.Cache): def clear(self, id): self.d = {} + sudscache = SudsCache() tns = "http://foo.bar.baz/soap/" @@ -200,6 +202,7 @@ def tosuds(client, value): def read_bool(value): return value == 'true' + soap_types = { 'xs:string': wsme.types.text, 'xs:int': int, @@ -244,6 +247,7 @@ def tobin(value): value = base64.decodestring(value.encode()) return value + fromsuds_types = { wsme.types.binary: tobin, wsme.types.bytes: tobytes,