pytest-django icon indicating copy to clipboard operation
pytest-django copied to clipboard

Option to keep db data after failed test in failfast mode ?

Open pakal opened this issue 5 years ago • 2 comments

When a test fails, it'd be very interesting to be able to explore the remaining test database, to better understand what happened. Of course it would be only in a "failfast" case, eg. "-x" flag of pytest.

Is it already possible to obtain that ? If not, how could it be introduced ? By commiting instead of rollbacking the test transaction, I guess ?

pakal avatar May 28 '19 06:05 pakal

Try --pdb - it will enter pdb for a failed test, and then you would have the DB there still (although in an atomic block (for db), i.e. not visible from outside of the test).

blueyed avatar May 28 '19 11:05 blueyed

Thanks for the hint, I hadn't thought about this.

In your opinion, would it be feasible (and robust) to have a flag to commit/keep the DB test data "when it's the last test" (eg. "-x" flag and the likes, I dunno if pytest easily informs about that), so that it can be more easily viewed from pycharm/heidisql and the like ? (if there are no obvious showstoppers regarding the architecture of pytest-django, I might have a look at it)

pakal avatar May 30 '19 09:05 pakal