Friday, May 6, 2016

Re: Fixtures won't load twice in same testcase

Hi Rich,

Regarding a couple of things you mentioned on Django-developers:

On Thursday, 5 May 2016 19:20:16 UTC+1, Rich Rauenzahn wrote:

Thanks, Tim.

Unfortunately I can't move past Django 1.7 yet -- dependencies.  I've been marching my way up one revision at a time hopefully up to 1.9 as a way to keep the scope of what breaks under control as I move through each major revision and stabilize my project.  Then I attack replacing dependencies.

I really think I've found a bug here ... which I hope to suggest a patch for and submit, hence the post to the developers channel, but I can go back to the users group for now... My recent experience with that list doesn't bode well, however, and I don't have high hopes with anyone there able to respond at the internals level I may need to track down the issue.  I've almost rewritten my tests to just load raw sql, but if there is a bug here I'd like to help find it rather than work around/ignore it.

Fixture loading was changed in Django 1.8 [1], so even if you have found a bug in Django 1.7, there's a good chance that behaviour will be different in Django 1.8 and later.


But In this particular run I'm currently tracing, rich is already in the db (as the only entry) as pk=5 (via fixture loading process).   For one, this tells me the sequence generators aren't always resetting between fixture loads/tests.

 
Sequences *are not* reset between test cases by default [2]. Perhaps you need to change your code so that it doesn't assume that the user has pk=1, or set reset_sequences = True.

It's difficult to offer any more advice, because you haven't posted any code that can reproduce the problem. It doesn't need to be the actual code, in fact the simpler the example is the better.

Cheers,
Alasdair

[1]: https://docs.djangoproject.com/en/1.9/releases/1.8/#testcase-data-setup
[2]: https://docs.djangoproject.com/en/1.9/topics/testing/advanced/#django.test.TransactionTestCase.reset_sequences

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d877ef6b-75d2-4197-85ab-9c0901e7ad95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment