I have the following in my conftest.py for exactly the purpose of inspecting the state of the request in tests.
class WebTestRequest(Request):
"""A custom WebTest request that allows access to Pyramid's Request."""
def __init__(
self,
environ: t.Dict,
charset: t.Optional[str] = None,
unicode_errors=None,
decode_param_names=None,
**kw
) -> None:
super(WebTestRequest, self).__init__(
environ, charset, unicode_errors, decode_param_names, **kw
)
# This allows us to get access to Pyramid request from WebTest
# response: resp.app_request
environ["paste.testing_variables"]["app_request"] = self
@pytest.fixture(scope="session")
def testapp(app: Router) -> WebTestApp:
"""Provide a webtest app for functional testing."""
app.request_factory = WebTestRequest
return WebTestApp(app)
Hope it helps,
z.
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
pylons-discus...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/pylons-discuss/38dca48c-d116-6ded-0f03-3a25658e14bf%40augusta.de.
> <OpenPGP_0x3EE6A5DC78826E6B.asc>