astraw38 / pytest-assume

A pytest plugin that allows multiple failures per test
MIT License
66 stars 16 forks source link

Make it work with already existing assertions #15

Open blueyed opened 5 years ago

blueyed commented 5 years ago

I think it would be very useful to turn existing asserts 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.

astraw38 commented 5 years ago

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.

Sup3rGeo commented 5 years ago

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.