<div dir="ltr">Hi Arun,<br><br><div class="gmail_quote"><div dir="ltr">On Wed, May 3, 2017 at 3:34 PM arun kali raja &lt;<a href="mailto:arunsep886@gmail.com">arunsep886@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>i am trying to implement a functionality in pytest through which user can re-run his testcase once the testcase is completed with some modifcations in his testcases.<br></div><div><br></div><div>I am trying to do this since i have a many fixtures running before the Testcases and  i dont want to go through the pain of executing all the fixtures when i want to run a failed test case sort.</div></div></blockquote><div><br></div><div>IIUC you want to re-use the fixture results in different test sessions, right? IOW:</div><div><br></div><div>$ pytest </div><div># some tests fail, update some code</div><div>$ pytest</div><div># run the failed tests, but reusing the fixture data from the 1st run</div><div><br></div><div>The only way to accomplish that AFAIK is to save the fixture data into disk somewhere, and change your fixture code to re-use that data if available instead of re-creating it from scratch.</div><div><br></div><div>You can use pytest&#39;s builtin cache for that:</div><div><br></div><div>Cache: working with cross-testrun state: <a href="https://docs.pytest.org/en/latest/cache.html#the-new-config-cache-object">https://docs.pytest.org/en/latest/cache.html#the-new-config-cache-object</a><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I was thinking of using the &quot;<span style="color:rgb(106,106,106);font-weight:bold">pytest_runtest_protocol&quot; </span>hook and since the item object has a runtest method i thought making some changes in my test file will reflect when i do a runtest again..<br></div><div><br></div><div>But that doesnt seem so. item has a attribute (not a member variable... just a scopeAttr) called module which points to the already compiled code and i am not able to override with my new compiled code.</div><div><br></div><div>I tried to delete my test package from sys.modules but that too doesnt help.</div></div></blockquote><div><br></div><div>I don&#39;t see how deleting things from `sys.modules` would help if you are in a different process than the first test run.</div><div><br></div><div>Cheers,</div><div>Bruno.</div></div></div>