Enable real testing of python 3.4

The gate 34 tests were not running any tests because there was no
tox target. This changes tox-tmpl.ini (and the resulting tox.ini) to
add support for python 34 and remove support for anything that is
not py34 or py27-based.

To make the python3 tox environments work, the remote zip of a suds
fork has been replaced with suds-jurko, a relatively modern fork of
the original suds that supports python2 and 3.

Some tests needed to be fixed to deal with two main problems:

* reponse bodies being bytes
* Exceptions not having a .message attribute (.args[0] is used
  instead)
* the test_flask tests were not being run for python3, they are now
* wsmeext/sphinxext.py intermittently fails due to the dictionary
  changing size in flight, getting the keys prior to iteration fixes
  it

Both 27 and 34 should be running 420 tests as of this commit.

Change-Id: I837c249714fd957790ea84aa2fd9ad994a39c5ea
This commit is contained in:
Chris Dent 2015-04-28 12:30:11 +01:00
parent c46e2b102e
commit 78d6b89d18
8 changed files with 176 additions and 737 deletions

View File

@ -180,7 +180,7 @@ class TestWS(FunctionalTest):
'/authors/913',
)
self.assertEqual(res.status_int, 200)
self.assertEqual(res.body, '"foo"')
self.assertEqual(res.body, b'"foo"')
self.assertEqual(res.content_length, 5)
def test_non_default_response_return_type_no_content(self):
@ -188,7 +188,7 @@ class TestWS(FunctionalTest):
'/authors/912',
)
self.assertEqual(res.status_int, 204)
self.assertEqual(res.body, '')
self.assertEqual(res.body, b'')
self.assertEqual(res.content_length, 0)
def test_serversideerror(self):

View File

@ -105,7 +105,7 @@ class FlaskrTestCase(unittest.TestCase):
def test_multiply(self):
r = self.app.get('/multiply?a=2&b=5')
assert r.data == '10'
assert r.data == b'10', r.data
def test_get_model(self):
resp = self.app.get('/models/test')
@ -118,9 +118,8 @@ class FlaskrTestCase(unittest.TestCase):
def test_array_parameter(self):
resp = self.app.get('/models?q.op=%3D&q.attr=name&q.value=second')
assert resp.status_code == 200
print resp.data
self.assertEquals(
resp.data, '[{"name": "second"}]'
resp.data, b'[{"name": "second"}]'
)
def test_post_model(self):
@ -154,9 +153,9 @@ class FlaskrTestCase(unittest.TestCase):
headers={'Accept': 'application/xml'}
)
assert r.status_code == 403, r.status_code
assert r.data == ('<error><faultcode>Client</faultcode>'
'<faultstring>403: Forbidden</faultstring>'
'<debuginfo /></error>')
assert r.data == (b'<error><faultcode>Client</faultcode>'
b'<faultstring>403: Forbidden</faultstring>'
b'<debuginfo /></error>')
def test_custom_non_http_clientside_error(self):
r = self.app.get(
@ -171,20 +170,17 @@ class FlaskrTestCase(unittest.TestCase):
headers={'Accept': 'application/xml'}
)
assert r.status_code == 412, r.status_code
assert r.data == ('<error><faultcode>Client</faultcode>'
'<faultstring>FOO!</faultstring>'
'<debuginfo /></error>')
assert r.data == (b'<error><faultcode>Client</faultcode>'
b'<faultstring>FOO!</faultstring>'
b'<debuginfo /></error>')
def test_serversideerror(self):
r = self.app.get('/divide_by_zero')
assert r.status_code == 500
data = json.loads(r.data)
self.assertEquals(
data,
{"debuginfo": None,
"faultcode": "Server",
"faultstring": "integer division or modulo by zero"}
)
self.assertEquals(data['debuginfo'], None)
self.assertEquals(data['faultcode'], 'Server')
self.assertIn('by zero', data['faultstring'])
def test_restful_get(self):
r = self.app.get('/restful', headers={'Accept': 'application/json'})

View File

@ -1,6 +1,6 @@
# content of: tox.ini , put in same dir as setup.py
[tox]
envlist = py26,py26-nolxml,py27,py27-nolxml,py32,py32-nolxml,pypy,tg11,tg15,cornice,coverage,py33,py33-nolxml,pecan-dev26,pecan-dev27,pecan-dev32,pecan-dev33,pep8
envlist = py27,py27-nolxml,pypy,tg11,tg15,cornice,coverage,py34,py34-nolxml,pecan-dev27,pecan-dev34,pep8
[common]
testtools=
@ -17,7 +17,7 @@ basedeps=
flask-restful
[axes]
python=py26,py27,py32,py33,pypy
python=py27,py34,pypy
sqlalchemy=sa5,sa6,sa7*
lxml=lxml*,nolxml
json=json*,simplejson
@ -26,58 +26,23 @@ json=json*,simplejson
deps =
{[common]testtools}
{[common]basedeps}
suds
suds-jurko
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
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
[axis:python:py26]
deps =
{[common]testtools}
unittest2
{[common]basedeps}
suds
basepython=python2.6
[axis:python:py27]
basepython=python2.7
[axis:python:py32]
basepython=python3.2
deps =
{[common]testtools}
{[common]basedeps}
https://bitbucket.org/bernh/suds-python-3-patches/downloads/suds_patched.zip
commands=
{envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest 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
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
[axis:python:py33]
basepython=python3.3
deps =
{[common]testtools}
{[common]basedeps}
https://bitbucket.org/bernh/suds-python-3-patches/downloads/suds_patched.zip
commands=
{envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py --verbose {posargs}
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
[axis:python:py34]
basepython=python3.4
[axis:sqlalchemy:sa5]
deps=
SQLAlchemy<=0.5.99
constraints=
!python:py32
[axis:sqlalchemy:sa6]
deps=
SQLAlchemy<=0.6.99
@ -90,9 +55,6 @@ deps=
deps=
simplejson
constraints=
!python:py32
[axis:lxml:lxml]
deps=
lxml
@ -101,50 +63,6 @@ deps=
setenv=
COVERAGE_FILE=.coverage.{envname}
[testenv:tg11]
basepython=python2.6
deps=
pbr
nose
webtest < 1.4.99
coverage < 3.99
simplejson
suds
lxml
commands=
{envbindir}/easy_install -i http://www.turbogears.org/1.1/downloads/current/index/ 'TurboGears<1.1.99'
{envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml tests/test_tg1.py --verbose --with-coverage --cover-package wsme,wsmeext {posargs}
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py
[testenv:tg15]
basepython=python2.6
deps=
pbr
nose
webtest < 1.4.99
coverage < 3.99
simplejson
suds
lxml
commands=
{envbindir}/easy_install -i http://www.turbogears.org/1.5/downloads/current/index/ 'TurboGears<1.5.99'
{envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml tests/test_tg15.py --verbose --with-coverage --cover-package wsme,wsmeext {posargs}
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py
[testenv:tg21]
basepython=python2.6
deps=
pbr
nose
coverage < 3.99
simplejson
commands=
{envbindir}/easy_install -i http://www.turbogears.org/2.1/downloads/current/index/ 'TurboGears2<2.1.99' webtest
{envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml tests/test_tg20.py --verbose {posargs}
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
[testenv:cornice]
basepython=python2.7
usedevelop=True
@ -161,31 +79,18 @@ commands=
[testenv:pecan-dev-base]
deps=
{[common]testtools}
webtest
transaction
suds
suds-jurko
https://github.com/stackforge/pecan/zipball/master
[testenv:pecan-dev26]
basepython=python2.6
deps={[testenv:pecan-dev-base]deps}
commands=
{envbindir}/nosetests tests/pecantest --with-xunit --xunit-file nosetests-{envname}.xml --verbose {posargs}
[testenv:pecan-dev27]
basepython=python2.7
deps={[testenv:pecan-dev-base]deps}
commands=
{envbindir}/nosetests tests/pecantest --with-xunit --xunit-file nosetests-{envname}.xml --verbose {posargs}
[testenv:pecan-dev32]
basepython=python3.2
deps={[testenv:pecan-dev-base]deps}
commands=
{envbindir}/nosetests tests/pecantest --with-xunit --xunit-file nosetests-{envname}.xml --verbose {posargs}
[testenv:pecan-dev33]
basepython=python3.3
[testenv:pecan-dev34]
basepython=python3.4
deps={[testenv:pecan-dev-base]deps}
commands=
{envbindir}/nosetests tests/pecantest --with-xunit --xunit-file nosetests-{envname}.xml --verbose {posargs}

736
tox.ini

File diff suppressed because it is too large Load Diff

View File

@ -225,7 +225,7 @@ def parse(s, datatypes, bodyarg, encoding='utf8'):
try:
kw = {argname: fromjson(datatypes[argname], jdata)}
except ValueError as e:
raise InvalidInput(argname, jdata, e.message)
raise InvalidInput(argname, jdata, e.args[0])
else:
kw = {}
extra_args = []
@ -236,7 +236,7 @@ def parse(s, datatypes, bodyarg, encoding='utf8'):
try:
kw[key] = fromjson(datatypes[key], jdata[key])
except ValueError as e:
raise InvalidInput(key, jdata[key], e.message)
raise InvalidInput(key, jdata[key], e.args[0])
if extra_args:
raise UnknownArgument(', '.join(extra_args))
return kw

View File

@ -383,7 +383,7 @@ class TestFormatException(unittest.TestCase):
return wsme_api.format_exception(fake_exc_info, debug=debug)
def test_format_client_exception(self):
faultstring = b'boom'
faultstring = 'boom'
ret = self._test_format_exception(exc.ClientSideError(faultstring))
self.assertIsNone(ret['debuginfo'])
self.assertEqual('Client', ret['faultcode'])
@ -397,7 +397,7 @@ class TestFormatException(unittest.TestCase):
self.assertEqual(faultstring, ret['faultstring'])
def test_format_server_exception(self):
faultstring = b'boom'
faultstring = 'boom'
ret = self._test_format_exception(Exception(faultstring))
self.assertIsNone(ret['debuginfo'])
self.assertEqual('Server', ret['faultcode'])
@ -411,7 +411,7 @@ class TestFormatException(unittest.TestCase):
self.assertEqual(faultstring, ret['faultstring'])
def test_format_server_exception_debug(self):
faultstring = b'boom'
faultstring = 'boom'
ret = self._test_format_exception(Exception(faultstring), debug=True)
# assert debuginfo is populated
self.assertIsNotNone(ret['debuginfo'])

View File

@ -437,10 +437,10 @@ class TestRestJson(wsme.tests.protocol.RestOnlyProtocolTestCase):
headers=headers,
status=406)
print("Received:", res.body)
assert res.body == ("Unacceptable Accept type: "
"text/html, application/xml;q=0.9 not in "
"['application/json', 'text/javascript', "
"'application/javascript', 'text/xml']")
assert res.body == b("Unacceptable Accept type: "
"text/html, application/xml;q=0.9 not in "
"['application/json', 'text/javascript', "
"'application/javascript', 'text/xml']")
def test_GET_bad_simple_accept(self):
headers = {
@ -451,9 +451,9 @@ class TestRestJson(wsme.tests.protocol.RestOnlyProtocolTestCase):
headers=headers,
status=406)
print("Received:", res.body)
assert res.body == ("Unacceptable Accept type: text/plain not in "
"['application/json', 'text/javascript', "
"'application/javascript', 'text/xml']")
assert res.body == b("Unacceptable Accept type: text/plain not in "
"['application/json', 'text/javascript', "
"'application/javascript', 'text/xml']")
def test_POST(self):
headers = {
@ -481,9 +481,9 @@ class TestRestJson(wsme.tests.protocol.RestOnlyProtocolTestCase):
headers=headers,
status=415)
print("Received:", res.body)
assert res.body == ("Unacceptable Content-Type: text/plain not in "
"['application/json', 'text/javascript', "
"'application/javascript', 'text/xml']")
assert res.body == b("Unacceptable Content-Type: text/plain not in "
"['application/json', 'text/javascript', "
"'application/javascript', 'text/xml']")
def test_DELETE(self):
res = self.app.delete(

View File

@ -560,9 +560,11 @@ class WSMEDomain(Domain):
}
def clear_doc(self, docname):
for name, value in self.data['types'].items():
keys = list(self.data['types'].keys())
for key in keys:
value = self.data['types'][key]
if value == docname:
del self.data['types'][name]
del self.data['types'][key]
def resolve_xref(self, env, fromdocname, builder,
type, target, node, contnode):