Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests are broken due to Werkzeug ImportError #352

Closed
twm opened this issue Aug 14, 2022 · 8 comments · Fixed by #353
Closed

Tests are broken due to Werkzeug ImportError #352

twm opened this issue Aug 14, 2022 · 8 comments · Fixed by #353
Labels

Comments

@twm
Copy link
Contributor

twm commented Aug 14, 2022

 Traceback (most recent call last):
  File "/home/runner/work/treq/treq/.tox/py39-twisted_latest/lib/python3.9/site-packages/twisted/trial/runner.py", line 596, in loadPackage
    module = modinfo.load()
  File "/home/runner/work/treq/treq/.tox/py39-twisted_latest/lib/python3.9/site-packages/twisted/python/modules.py", line 389, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File "/home/runner/work/treq/treq/.tox/py39-twisted_latest/lib/python3.9/site-packages/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/home/runner/work/treq/treq/.tox/py39-twisted_latest/lib/python3.9/site-packages/twisted/python/reflect.py", line 244, in _importAndCheckStack
    raise excValue.with_traceback(excTraceback)
  File "/home/runner/work/treq/treq/.tox/py39-twisted_latest/lib/python3.9/site-packages/treq/test/local_httpbin/test/test_child.py", line 28, in <module>
    from .. import child, shared
  File "/home/runner/work/treq/treq/.tox/py39-twisted_latest/lib/python3.9/site-packages/treq/test/local_httpbin/child.py", line 11, in <module>
    import httpbin
  File "/home/runner/work/treq/treq/.tox/py39-twisted_latest/lib/python3.9/site-packages/httpbin/__init__.py", line 3, in <module>
    from .core import *
  File "/home/runner/work/treq/treq/.tox/py39-twisted_latest/lib/python3.9/site-packages/httpbin/core.py", line 21, in <module>
    from werkzeug.wrappers import BaseResponse
builtins.ImportError: cannot import name 'BaseResponse' from 'werkzeug.wrappers' (/home/runner/work/treq/treq/.tox/py39-twisted_latest/lib/python3.9/site-packages/werkzeug/wrappers/__init__.py)
@twm twm added the bug label Aug 14, 2022
@twm twm changed the title Tests are broken due to Werukzeug ImportError Tests are broken due to Werkzeug ImportError Aug 14, 2022
@SamirPS
Copy link

SamirPS commented Aug 14, 2022

Hello,

It's because it's deprecated, pallets/werkzeug#2360 (comment)

Quick fix : Werkzeug==2.0.3

@twm
Copy link
Contributor Author

twm commented Aug 14, 2022

@SamirPS Thanks, that is more specific than the pin I was using!

Ultimately, it's because httpbin is unmaintained since 2018. 😞 I'll fix this by pinning for the moment and file another ticket to address the larger issue.

@SamirPS
Copy link

SamirPS commented Aug 14, 2022

No problem,
You can't use another library ?

@twm
Copy link
Contributor Author

twm commented Aug 14, 2022

@SamirPS Is there another implementation of httpbin? We ended up here because our integration test suite used to hit httpbin.org, but of course this required internet access and was flaky. Right now the tests run httpbin in a subprocess.

There's some value in having integration tests that do real I/O, but IMO some of what we are testing this way would be better done using in-memory techniques like treq.testing.

Maybe we end up reimplementing the bits of httpbin we need in Twisted?

@SamirPS
Copy link

SamirPS commented Aug 14, 2022

Maybe try this

postmanlabs/httpbin#673 (comment)

@arnimarj
Copy link

arnimarj commented Aug 15, 2022

I've been doing this in my tests:

	import werkzeug.wrappers
	Response = werkzeug.wrappers.Response
	werkzeug.wrappers.BaseResponse = Response  # type: ignore[attr-defined]

...and doing it before I import httpbin (I've been running httpbin under WSGIResource with some hacks).

EDIT: I'm running httpbin in process, not as a separate process like the treq tests are apparently doing

@SamirPS
Copy link

SamirPS commented Aug 15, 2022

Where the werkzeug is localized the source code?

@twm
Copy link
Contributor Author

twm commented Aug 21, 2022

@SamirPS It's not — Werkzeug is used by httpbin, not treq.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants