pytest-assume
pytest-assume copied to clipboard
Make it work with already existing assertions
I think it would be very useful to turn existing assert
s into assumptions sometimes temporarily, e.g. with a test where you want to see all assertion failures, without disabling/commenting them.
I've thought about suggesting this for pytest itself, but then remembered this plugin.
Do you think it is possible to change / override pytest's assertion's on-demand?
To be clear: my use case is turning this behavior on via some flag on demand, and I know that it is useful for certain kinds of tests only.
I think this would likely be very closely related to #4 , at least in regards to location/type of work required. I think it would need to be an AST rewrite because (as far as I know) there's no good way to catch all AssertionErrors in a test, and resume at that point it happened.
It would make sense to merge this plugin to pytest core as a "soft assertion" feature and indeed have this in the assertion rewrite module.