#20392: Rearrange transactional behavior in django.test.TestCase: savepoints around tests -------------------------------------+------------------------------------- Reporter: xelnor | Owner: smeatonj Type: New feature | Status: assigned Component: Testing framework | Version: master Severity: Normal | Resolution: Keywords: test atomic | Triage Stage: Accepted savepoint | Needs documentation: 0 Has patch: 0 | Patch needs improvement: 0 Needs tests: 0 | UI/UX: 0 Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by xelnor): I'd side with aaugustin on that one: the contract of `TestCase` is "whatever happens in the database during the `test_` is temporary; if you use fixtures, they will be cleaned afterwards; be careful when creating instances in `setUpClass`." I don't think there is any documentation stating that "if you want to reuse data created in `setUpClass` in other Cases, it will work", nor that this would actually be a good idea. Currently, users who create objects in `setUpClass` carefully remove them during `tearDownClass`, and so the only tests that would be broken by this change would be tests where "one `TestCase` relies on the `setUpClass` of another one to have run before", which sounds pretty broken to me. If you feel that users should be allowed to mess with transactions, this could be done with a simple class attribute, similar to `fixtures = `. Besides, any improvement to Django's test suite is likely to benefit big projects using Django as well; please don't make them "hidden" for the sake of backwards-compatibility on undocumented behavior ;) -- Ticket URL: <https://code.djangoproject.com/ticket/20392#comment:17> 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/064.63ddcdf5a707cba4dd15aa5c852b62f4%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.