Django: Trivial Patch



, , ,

Last night I ran across a deprecation warning when running startproject <projectname>, so I went to file a ticket but found that someone else had experienced the same problem. I looked at the solution, and on the surface it looked like the fix involved replacing from whrandom import choice to from random import choice. Indeed that was all it took, so I submitted a (trivial) patch and continued to bang on Django a bit more.

That trivial patch made me really wish that there were unit tests for Django. I would have felt a lot better knowing that after applying my patch n tests still passed with flying colors. Without a test framework in place, I really had no idea if my trivial search and replace broke something. It’s possible that somewhere in the code was really expecting some behavior specific to whrandom that was just slightly different than the behavior of random.

I’m going to hunt around for other little trivial fixes that don’t require carnal knowledge of the codebase and submit patches if I can come up with a fix. At the same time I hope that Nelson’s test suite ticket gets noticed. I wouldn’t mind doing some of the dirty work once a framework is in place, but as always I defer to Adrian and the core Django team when it comes to policy and implementation.


4 responses to “Django: Trivial Patch”

  1. Simon Willison Avatar

    Unit tests are definitely one of the key things missing from Django. I have an ambition to write a set of unit tests for the database stuff (to ensure that the postgres, mysql and sqlite backends are all operating at the same level of completeness) but it could take me a while to do.

    If you’re interested in helping out getting some unit tests going for Django, I’m sure Adrian and Jacob would be happy to hear from you on IRC.

  2. matt Avatar


    I also ran into a
    lack of unit tests recently. Seems that many projects believe that testing is something that end users do…

  3. 3a7c9c563592…


  4. EZuMdxO Avatar