#11665: django.test.TestCase should flush constraints
------------------------------------+-----------------------------------
               Reporter:  Glenn     |          Owner:
                   Type:  Bug       |         Status:  new
              Milestone:            |      Component:  Testing framework
                Version:  SVN       |       Severity:  Normal
             Resolution:            |       Keywords:
           Triage Stage:  Accepted  |      Has patch:  1
    Needs documentation:  0         |    Needs tests:  0
Patch needs improvement:  1         |  Easy pickings:  0
                  UI/UX:  0         |
------------------------------------+-----------------------------------

Comment (by jsdalton):

 Here's an improved patch that gets us closer. Basically this one starts to
 fix the errors that come up once you enable production-like constraint
 checking. You can see the commits here:
 
https://github.com/jsdalton/django/commits/better_constraint_checks_during_testing
 but in a nutshell:

 * I reworked the `check_constraints()` feature (from #3615) a bit to
 ensure we *don't* check constraints if the constraint_checking_disabled
 context manager is in effect. This prevented a regression that occurred in
 fixture loading when the new `check_constraints()` function I added to
 `django.test.testcases` got executed.

 * Flush the `ContentType` cache during tests, which cleared up some issues
 in `egression_tests.multiple_database`. Also fixed an `assertNumQueries`
 count after the change, since a new contenttype select was being executed.

 * Add `@ignore_num_queries decorator`. Basically, because the
 `check_constraints()` implementation can have a varying number of SQL
 statements depending on the backend, I implemented a decorator that
 prevents `assertNumQueries` from counting queries on any statements
 executed during a decorated function. For now just added it to
 `django.test.testcases.check_constraints()`.

 Any comments on the above? This work starts to deviate a bit from this
 ticket, but it's required to get tests passing.

 This gets us to 3 tests away from passing all tests in Postgresql, with
 correct constraint checking. The only 3 tests we're missing now in
 `multiple_database`. I know ramiro had done some work on some of these. I
 guess I'll sit down with them at some point, but I'm kind of a bit
 stuck... If anyone has thoughts I'd love to hear them.

 Next up for me is hitting the remaining failiures on MySQL. Almost
 there...

-- 
Ticket URL: <https://code.djangoproject.com/ticket/11665#comment:26>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to