#31395: Make TestCase.setUpTestData enforce in-memory data isolation.
---------------------------------------------+------------------------
               Reporter:  Simon Charette     |          Owner:  nobody
                   Type:  New feature        |         Status:  new
              Component:  Testing framework  |        Version:  3.0
               Severity:  Normal             |       Keywords:
           Triage Stage:  Unreviewed         |      Has patch:  0
    Needs documentation:  0                  |    Needs tests:  0
Patch needs improvement:  0                  |  Easy pickings:  0
                  UI/UX:  0                  |
---------------------------------------------+------------------------
 [https://groups.google.com/d/msg/django-
 developers/wOOlWBJYo2Y/FKj7fqPWAgAJ The following is copied from a two
 years old django-developers thread that received an initial warm welcome].


 Since then the [https://github.com/charettes/django-testdata third-party
 app] implementing this feature has not received much feedback but I know a
 few developers have been using it and my usage in a few projects didn't
 surface any issues.

 ---

 Django 1.8 introduced the `TestCase.setUpTestData()` class method as a
 mean to
 speed up test fixtures initialization as compared to using `setUp()`.

 As I've come to use this feature and review changes from peers using it in
 different projects the fact that test data assigned during its execution
 couldn't be safely altered by test methods without compromising test
 isolation
 has often be the source of confusion and frustration.

 While the `setUpTestData` documentation mentions this limitation[1] and
 ways to
 work around it by using `refresh_from_db()` in `setUp()` I believe it
 defeats
 the whole purpose of the feature; avoiding unnecessary roundtrips to the
 database to speed up execution. Given `TestCase` goes through great
 lengths to
 ensure database level data isolation I believe it should do the same with
 class
 level in-memory data assigned during `setUpTestData`.

 In order to get rid of this caveat of the feature I'd like to propose an
 adjustment to ensure such in-memory test data isolation.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31395>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.7111f7f37ff464c126499c2465b05fc0%40djangoproject.com.

Reply via email to