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

Provide stage to before_every_request hook #716

Open
rjrudin opened this issue Sep 29, 2021 · 2 comments
Open

Provide stage to before_every_request hook #716

rjrudin opened this issue Sep 29, 2021 · 2 comments

Comments

@rjrudin
Copy link

rjrudin commented Sep 29, 2021

The pytest_tavern_beta_before_every_request hook is very handy for logging each request as a test runs. But endpoint URLs aren't always that self-documenting, sometimes leaving the developer thinking - hmm, I wonder what the call just did?

The "name" of a stage seems to be a great way to describe what a call is expected to do. I'd really like to include this in the logs for every request, but I don't have access to that based on the current hook interface. The goal would be that a developer - particularly one new to the project - could run a Tavern test and watch the logs to see not only what calls are being made (and how long each takes, which can be informative), but also what the call is expected to do,

I'm wondering if the entire stage config could be passed to the before_every_request hook, which of course would include the url, which is my primary motivation.

@michaelboulton
Copy link
Member

From the description I think this would fall under the topic of having a way of running a generic function before/after each request in a stage like in #114 ? The current pytest hooks for 'before every request' and 'after every response' were a bit of a stopgap for that.

In the meantime, if you do want to be able to provide a view of what requests are doing and how long they take you could try using the allure support (example) but this obviously isn't exactly what you want.

@rjrudin
Copy link
Author

rjrudin commented Dec 13, 2021

I think #114 would address this need, assuming that the "context" object provides the stage config, which it presumably would. And I like the semantics of "before" and "after" vs the current stopgap hooks. I am fine then with this ticket being closed and linked to via #114 as an example of what 114 could address.

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

No branches or pull requests

2 participants