Opened 4 months ago

Last modified 4 months ago

#35722 closed Cleanup/optimization

Specify behaviour in TransactionTestCase.reset_sequences — at Initial Version

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

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()"

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top