Wednesday, April 27, 2011

Running tests automatically as you work.

http://dpaste.com/hold/536487/

I cobbled this little script together that monitors my project folder
and runs tests every time a .py file is saved. I'm sharing it in case
anyone is interested. Feedback is welcome, of course.

Interesting bits:

pyinotify: This module plugs into kernel notifications so you don't
have to do something horrible like put os.walk in a loop.

call_command: Kenny Meyer pointed this out to me. It lets you run
'manage.py' commands from a Python script.
http://docs.djangoproject.com/en/dev/ref/django-admin/#running-management-commands-from-your-code

SystemExit: When sys.exit() is called, you can't catch it with
"except Exception," because it has a different base class.
Thanks to Alex Gaynor for helping me with this one.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment