#35722: Specify behaviour in TransactionTestCase.reset_sequences
-------------------------------------+-------------------------------------
     Reporter:  Slava M.             |                    Owner:  (none)
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Documentation        |                  Version:  dev
     Severity:  Normal               |               Resolution:
     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
-------------------------------------+-------------------------------------
Description changed by Slava M.:

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

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

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35722#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070191a2c473b0-570bc44c-9c17-45bf-9de5-bf691e4036d0-000000%40eu-central-1.amazonses.com.

Reply via email to