#20579: Define the expected state of the database between test cases -----------------------------------+------------------------------------- Reporter: aaugustin | Owner: aaugustin Type: Bug | Status: new Component: Testing framework | Version: master Severity: Release blocker | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------------+-------------------------------------
Comment (by aaugustin): I had spent half an hour carefully writing down my research, going back to the introduction of TransactionTestCase, only to lose my text to a bad key combo. Lesson learnt: Firefox doesn't consider Trac's comment field as an input field, and won't preserve its content across Back / Next :'( I'm too lazy to re-write it all. ---- To sum up, I was proposing to: - Trigger post_syncdb at the beginning of TransactionTestCase => ensures required CTs and permissions exist. - Flush without triggering post_syncdb at the end of TransactionTestCase => avoids creating thousands of CTs and permissions, preserving the benefits of #20483. This introduces one noticeable change compared to Django 1.5: after a TransactionTestCase, CTs and permissions tables will be empty. This isn't a problem for CTs because they're created on the fly when they're missing -- get_for_model actually does_create_for_model. It could be a problem for permissions. ---- It could also be a problem for doctests. Carl says: ''there is no longer any special support for doctests in Django (or well, there is, but it is deprecated); doctests are still fully "supported" in the sense that they are part of Python and can be integrated with a unittest test suite in the manner recommended in the Python docs; that integration has to be explicit, doctests are not automatically discovered; see http://docs.python.org/2/library/doctest.html#unittest-api''. Currently, the reordering of the test suite runs all subclasses `django.test.TestCase` first, and then everything else -- including TransactionTestCase and doctests turned into `unittest.TestCase`. As a consequence, if someone's running doctests that rely on permissions, this proposal would break them. To play safe, we could perform this steps only when available_apps isn't None. This makes available_apps even more of a hack specific to Django's own test suite, but it never was anything else anyway... Thoughts? -- Ticket URL: <https://code.djangoproject.com/ticket/20579#comment:1> 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 unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.e0e960b4ae7efd9263ac525e6e51ef6d%40djangoproject.com?hl=en. For more options, visit https://groups.google.com/groups/opt_out.