-
Notifications
You must be signed in to change notification settings - Fork 347
Support reset sequences #619
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
Support reset sequences #619
Conversation
1a75381
to
db26027
Compare
Codecov Report
@@ Coverage Diff @@
## master #619 +/- ##
==========================================
+ Coverage 92.36% 92.54% +0.18%
==========================================
Files 32 32
Lines 1715 1757 +42
Branches 142 149 +7
==========================================
+ Hits 1584 1626 +42
Misses 94 94
Partials 37 37
Continue to review full report at Codecov.
|
Would be nice to get the diff covered 100%: https://codecov.io/gh/pytest-dev/pytest-django/compare/db44ccfdcc2fb710a731ca32efb6929824b50c44...db260270b074e8692cbfe51c0825d88b7b319dcf/diff |
btw: thanks for improving the docs - I think it would make sense to only have it in one place though, and then use Sphinx' |
|
Thanks for your summary!
I feel like it would add the most flexibility, and could be a good base for Re docs:
I agree that it might be out of scope, but wanted to mention it since you are documenting the fixture in two places, but a single one would suffice: https://github.com/pytest-dev/pytest-django/pull/619/files#diff-352a76c86a6f0e0377970c01375e1e39R231 and https://github.com/pytest-dev/pytest-django/pull/619/files#diff-b8d58f3cc3175f8ec7bc9441f7d0bd32R191. |
docs/helpers.rst
Outdated
values (e.g. primary keys) before running the test. Defaults to | ||
``False``. Must be used together with ``transaction=True`` to have an | ||
effect. Please be aware that not all databases support this feature. | ||
For details see `django.test.TransactionTestCase.reset_sequences`_ |
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.
You can use intersphinx here:
diff --git i/docs/helpers.rst w/docs/helpers.rst
index 78e62ee..e2cfede 100644
--- i/docs/helpers.rst
+++ w/docs/helpers.rst
@@ -45,7 +45,7 @@ test will fail when trying to access the database.
values (e.g. primary keys) before running the test. Defaults to
``False``. Must be used together with ``transaction=True`` to have an
effect. Please be aware that not all databases support this feature.
- For details see `django.test.TransactionTestCase.reset_sequences`_
+ For details see :py:attr:`django.test.TransactionTestCase.reset_sequences`.
.. note::
@@ -63,7 +63,6 @@ test will fail when trying to access the database.
Test classes that subclass Python's ``unittest.TestCase`` need to have the
marker applied in order to access the database.
-.. _django.test.TransactionTestCase.reset_sequences: https://docs.djangoproject.com/en/dev/topics/testing/advanced/#django.test.TransactionTestCase.reset_sequences
.. _django.test.TestCase: https://docs.djangoproject.com/en/dev/topics/testing/overview/#testcase
.. _django.test.TransactionTestCase: https://docs.djangoproject.com/en/dev/topics/testing/overview/#transactiontestcase
You can use python -msphinx.ext.intersphinx https://docs.djangoproject.com/en/dev/_objects/ | less
to see the available targets.
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.
Nice! Adjusted it likewise.
What do you think concerning this PR - would you like to change the approach how it is done or do you see it in a merging state whereas issues in #431 and #353 can be solved in a different context? |
I think this PR is fine for now! |
@sliverc I am happy you have picked this up, thanks and cheers 🤗 |
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.
c6b33ec
to
04f117b
Compare
Rebased, planning to add it to the next release / merge it soon. |
Picking up work done in #308
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 when you have tests that rely on such values, like ids or other primary keys such as snapshot testing of apis with snapshottest.