pytest
pytest copied to clipboard
Mention `monkeypatch.undo()` in the docs
It was never mentioned in the docs, and I keep forgetting that it's .undo() and not .stopall() or something...
- [ ] Include documentation when adding new features.
- [ ] Include new tests or update existing tests when applicable.
- [ ] Allow maintainers to push and squash when merging my commits. Please uncheck this if you prefer to squash the commits yourself.
Given how monkeypatch works, undo undoes all of them, using the context context manager may be the better detail to recommend
Given how monkeypatch works, undo undoes all of them, using the context context manager may be the better detail to recommend
Why not both? We added .context() in #10143.
Undo is a footgun that may undo patches of other fixtures
In fact, since we have contex, I'm in favour of deprecation of undo
In fact, since we have contex, I'm in favour of deprecation of undo
I would prefer not... this would force all users to update perfectly working code.
I think a better approach would to update the undo() docs to strongly recommend using a context() instead.
I think a better approach would to update the undo() docs to strongly recommend using a context() instead.
Took the liberty of doing that and pushing it to this branch. Also improved the docs a bit by adding cross-links.
@nicoddemus i believe that there are next to no valid uses of undo, as it always affects the whole monkeypatch object, which is not safely usable in most cases
@RonnyPfannschmidt you are commenting about deprecating undo(), right? If so I think we should move that discussion to a new issue/proposal.
Or do you mean to have new changes in the PR?
True, let's move that into a own task
@RonnyPfannschmidt (and others), regardless of the discussion about deprecating undo(), I think the PR is still good to be merged. 👍
Thanks @RonnyPfannschmidt! 👍
@webknjaz would appreciate if you could take a look at my changes too. 😁
@nicoddemus love the improvements, thanks!