#35722: Specify behaviour in TransactionTestCase.reset_sequences
-------------------------------------+-------------------------------------
Reporter: Slava M. | Type:
| Cleanup/optimization
Status: new | Component:
| Documentation
Version: dev | Severity: Normal
Keywords: docs, test, | Triage Stage:
documentation | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
https://docs.djangoproject.com/en/dev/topics/testing/advanced/#django.test.TransactionTestCase.reset_sequences
I suggest specifying behaviour of
{{{TransactionTestCase.reset_sequences}}} when used in subtests
https://docs.python.org/3/library/unittest.html#distinguishing-test-
iterations-using-subtests.
i.e.
{{{
class TestsThatDependsOnPrimaryKeySequences(TransactionTestCase):
reset_sequences = True
def test_animal_pk(self):
with self.subTest():
lion = Animal.objects.create(name="lion", sound="roar")
# will this still work?
self.assertEqual(
lion.pk, 1)
}}}
add to documentation 1 sentence along the lines of:
* "**reset_sequences** won't work with **unittest**'s **subTest()**"
* or ""**reset_sequences** also works with **unittest**'s **subTest()**"
--
Ticket URL: <
https://code.djangoproject.com/ticket/35722>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.