-
Notifications
You must be signed in to change notification settings - Fork 347
Support reset_sequences #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
``transactional_db``, with additional support for reset of auto increment | ||
sequences (if your database supports it). This is only required for | ||
fixtures which need database access themselves. A test function would | ||
normally use the :py:func:`~pytest.mark.django_db` mark to signal it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/mark.django_db/mark.reset_sequences_db/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry, I don't understand 😕 Is that sphinx syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sed
.. ;)
Change "mark.django_db" to "mark.reset_sequences_db".
It seems you have copied it from the paragraph above, but it should be changed here - if I understand it correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh okay 😌 ! There is only one marker (django_db
), but it has some optional keywords that make the difference. I updated that section of the docs to make it clear which one to use for a test to get the same effect as using the fixture.
Awesome, thanks! |
Thanks for your review @blueyed 🙇 ! |
Any news on this? |
Thanks for the PR! It mostly looks good and this would be a very useful feature. A couple of notes/things that I think should be changed before merge: This PR changes the return value of |
Hi Andreas, you are probably right about me taking a nasty shortcut there 😊 I will look into it and try to resolve it as you proposed. Thanks for the review 🙇 |
I might find time to work at this tomorrow, but not sure. If you want to do it yourself, please go ahead! I hope you enjoy the sprint guys, give a shout to @hackebrot for me please 😄 |
@cb109 💩 |
👊 😆 |
@cb109 feel free to continue working in this, it would for sure be a useful feature! :) |
This breaks the test for the reset_sequences feature.
We actually check for the resulting sequence ids now instead of internal pytest-django-attributes. On the flipside this test must now be skipped if the current database does not support the feature.
I refactored the test to use |
@cb109 Thanks for keeping up the work in this PR! I think the Travis builds have not been run because automatic merge with master failed -- can you try to merge with the latest master and push again to the PR and see if it gets picked up? I think the fixture should be renamed to |
@pelme Alright I will rename it once travis is green. It is weird to see some postgresql configurations succeed and others fail, no idea yet what the problem is. |
Well, being honest with myself I will probably not get back to this, so let's close it off to not be a burden for you guys. As far as I remember some travis tests where failing and I couldn't figure out why, while the actual feature seemed only supported by very few database setups on top. I have since come to write tests to not rely on ids at all, which I guess is good practice anyway, so there isn't much motivation left to finish this off. Sorry and thanks for your help on this nonetheless! |
This adds support for using the reset_sequences feature of Django's TransactionTestCase.
It will try to reset all automatic increment values before test execution, if the database supports it. This is useful for when you have tests that rely on such values, like ids or other primary keys.
Please let me know your thoughts.