[pytest-dev] re-running pytest on file changes

Tom Viner tom at viner.tv
Sun Mar 29 00:12:13 CET 2015


I find it really helps TDD to have my tests run automatically whenever I
change either a test or the code itself. I set my editor (Sublime Text 3)
to auto save upon defocus, so it's actually impossible to avoid a test
rerun whenever I alter a file and move on or hit save.

For this, I regularly use Jonathan Hartley's rerun Python library[0] which
gives the ability to wrap my py.test or tox command like so:

rerun --ignore sqlite.db "py.test tests/"

The --ignore part is very important, as different test suites end up
altering various working directory files, and if you can't select
files/folders (file patterns would be even better) to ignore, you end up in
an un-pausing loop of test reruns.

I hadn't heard of looponchange can it ignore certain files/folders?

[0] https://pypi.python.org/pypi/rerun



> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 27 Mar 2015 14:55:31 +0000
> From: Tibor Arpas <tibor.arpas at infinit.sk>
> To: "pytest-dev at python.org" <pytest-dev at python.org>
> Subject: [pytest-dev] re-running pytest on file changes
> Message-ID:
>         <
> CADi_WY3cbDAOfDS8+oV5iRoF6qzvjsX+_PSmcBK-Ss1uObGCxA at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi,
>
> I'm trying to wrap my head around this subject.
>
> Is there a strong reason why the -f looponfail option is inside a plug-in?
> My hunch would be to do it as a separate, flexible, command, but that's
> just feelings without any experience.
>
> Poll: Do you guys use looponfail? Has it been working good? Does it play
> nice with other tasks you might want to do on file changes? What other
> tools do you use for repeated tasks on source code changes?
>
> What's the situation at the moment with --looponfail and --looponchange? Is
> it going to be inside pytest_cache which will go into core? Or it will be a
> different plug-in?
>
> I've seen
> https://bitbucket.org/pytest-dev/pytest/commits/b5727cc6632c/
>
> and the "take in cache" PR.
>
>
> Tibor
> P.S. some more thoughts about the same functionality are here:
> https://github.com/tarpas/testmon/issues/4
> and a script whith callbacks for every success and failure:
> https://github.com/blueyed/testmon/blob/tmon-improvements/testmon/tmon.py
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/pytest-dev/attachments/20150327/a09d699c/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> pytest-dev mailing list
> pytest-dev at python.org
> https://mail.python.org/mailman/listinfo/pytest-dev
>
>
> ------------------------------
>
> End of pytest-dev Digest, Vol 28, Issue 22
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20150328/4297de10/attachment-0001.html>


More information about the pytest-dev mailing list