[PATCH v2 07/16] tests: Move 'reverse' calls inside 'setUp'

Finucane, Stephen stephen.finucane at intel.com
Fri Sep 18 04:28:20 AEST 2015


> On Fri, Aug 21, 2015 at 03:32:11PM +0100, Stephen Finucane wrote:
> > Django creates test databases after it loads tests. However, any
> > operations that exist at class level will be executed before this
> > database is created. Fix the instances of this issue (mostly 'reverse'
> > calls or similar) by moving the calls into the relevant 'setUp'
> > functions for each test.
> >
> > Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
> 
> I still don't get why the reverse() calls at the class level are
> problematic as they don't do any DB operation, mind enlightening me?
> 
> --
> Damien

I'm trying to find the article where I found this link, but I haven't been able to yet. You can test this yourself though: delete and recreate your database table but don't execute the 'migrate' step. Try running the tests without this check - you'll get failures on those 'reverse' commands.

Not that it's a reason to merge this, but it's worth noting that this change won't inherently break anything.

Stephen


More information about the Patchwork mailing list