Missing errors in missing fixtures in django unit test

Is there a way to see errors when django unit tests load devices?

It is annoying that something like a missing file, duplicate keys or files with poorly formatted files does not appear as an error when starting the django unit test.

+3
source share
2 answers

If duplicate primary keys generated an error while loading the instrument, many existing tests will be violated. Sometimes the device must contain this error, so it can be tested against.

You can write general tests to check for the problems you mentioned:

  • , , , . , (, YourObject.objects.get(pk=1) YourObject.objects.get(name='My Test Entry').

  • , , YourObject.objects.all().aggregate(Count('id', distinct=True)) YourObject.objects.all().aggregate(Count('id')). , .

  • , . manage.py dumpdata .

. .


- loaddata. , fixtures = [] , . , loaddata , . , " " 2 .

Django Django .

+1

setUp(). , , , , .

0

All Articles