#25493: Model instances created with unittest.mock can raise confusing errors
-------------------------------------+-------------------------------------
     Reporter:  Josh Smeaton         |                    Owner:  Marcelo
         Type:                       |  Galigniana
  Cleanup/optimization               |                   Status:  assigned
    Component:  Database layer       |                  Version:  1.9
  (models, ORM)                      |
     Severity:  Normal               |               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 Adam Johnson):

 unittest.mock is a blunt testing tool which I discourage the use of,
 especially for complex things like the ORM. If you’re using it to replace
 parts of a system, it’s your responsibility to make that work. I don’t
 believe we should try to make the ORM more compatible with parts being
 mocked.

 If you’re mocking to try speed up tests, there are some safer techniques
 to try first. Use setUpTestData to create shared model instances (see my
 post: https://adamj.eu/tech/2021/04/12/how-to-convert-a-testcase-from-
 setup-to-setuptestdata/ ), or use unsaved instances inside a
 SimpleTestCase.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/25493#comment:5>
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/0107018d9eb32699-d286d8f4-0d59-4fb2-962b-79aaafde0647-000000%40eu-central-1.amazonses.com.

Reply via email to