ipytest icon indicating copy to clipboard operation
ipytest copied to clipboard

Remove random_module_path in case it exists

Open AlmogBaku opened this issue 1 year ago • 3 comments

Stopping/terminating a cell in the middle can cause the file not to be deleted. In this case, we should delete it instead of throwing an error

https://github.com/chmp/ipytest/blame/09b7ff6a1990b88de52da565b86fac7ff63e2f37/ipytest/_impl.py#L425-L426

AlmogBaku avatar Jan 26 '25 12:01 AlmogBaku

Good point. Never ran into this issue before. Out of interest: is there anything specific you're code is doing?

But looking at the code it seems to be an issue (nice touch using blame btw ;)). Probably it's better though to log a warning and instead use the file as-is. If the file was created deliberately, deleting it could cause all kinds of havoc.

chmp avatar Jan 27 '25 21:01 chmp

im running a long-running tests (LLM evaluations) with https://github.com/AlmogBaku/pytest-evals

it's an open source I wrote that works with your library :)

AlmogBaku avatar Jan 28 '25 12:01 AlmogBaku

with the recent version(released yesterday) of my project I wrote a new ipython magic that wraps ipytest with a fix for this bug... it seems to work see https://github.com/AlmogBaku/pytest-evals/blob/master/src/pytest_evals/ipython_extension.py#L42

AlmogBaku avatar Jan 28 '25 12:01 AlmogBaku