Opened 3 months ago
Last modified 3 months ago
#35722 closed Cleanup/optimization
Specify behaviour in TransactionTestCase.reset_sequences — at Version 1
Reported by: | Slava M. | Owned by: | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | docs, test, documentation |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
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") self.assertEqual(lion.pk, 1) with self.subTest(): cat = Animal.objects.create(name="cat", sound="meow") # will this still work? self.assertEqual(cat.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()"
Note:
See TracTickets
for help on using tickets.