Pylons / webtest

Wraps any WSGI application and makes it easy to send test requests to that application, without starting up an HTTP server.
https://docs.pylonsproject.org/projects/webtest/en/latest/
Other
335 stars 109 forks source link

Webtest fails with PYTHONOPTIMIZE=2 #208

Closed therefromhere closed 5 years ago

therefromhere commented 5 years ago

It seems that webtest currently doesn't support enabling full python optimization with PYTHONOPTIMIZE=2, is this a known issue?

To Reproduce

  1. Run tests with enviroment PYTHONOPTIMIZE=2

eg:

TOX_TESTENV_PASSENV=PYTHONOPTIMIZE PYTHONOPTIMIZE=2 tox
  1. See error
tests/test_app.py:5: in <module>
    from webtest.compat import to_bytes
webtest/__init__.py:9: in <module>
    from webtest.app import TestApp
webtest/app.py:89: in <module>
    class TestApp(object):
webtest/app.py:466: in TestApp
    post_json = utils.json_method('POST')
webtest/utils.py:39: in json_method
    wrapper.__doc__ = json_method.__doc__ % subst
E   TypeError: unsupported operand type(s) for %: 'NoneType' and 'dict'

This code is trying to update the docstring, which doesn't exist under PYTHONOPTIMIZE=2

Expected behavior Tests to pass.

gawel commented 5 years ago

I guess __doc__ is removed when optimizing

a try/except on this one should fix the issue.