Hi,
I have an hard time understanding how I am supposed to use setUpTestData.
The documentation isn't very clear about it
(https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.TestCase.setUpTestData).
"The class-level atomic block described above allows the creation of
initial data at the class level, once for the whole TestCase.". and "Note
that if the tests are run on a database with no transaction support (for
instance, MySQL with the MyISAM engine), setUpTestData() will be called
before each test, negating the speed benefits." let me think that the
changes made by the test should be rollbacked after each test.
So I would expect the following to works:
class OrderBugTest(TestCase):
@classmethod
def setUpTestData(cls):
cls.order = OrderFactory()
cls.order.go_available()
cls.order.go_suspended()
def test_1(self):
""" Ok. """
self.order.go_completed()
self.assertEqual(self.order.state, 'completed')
def test_2(self):
""" Fails, order is modified from test_1. """
self.assertEqual(self.order.state, 'suspended')
Does this means only static data should be created this way ? Can't I
modify data created this way in the test ? Am I doing something wrong ?
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/da2fb4a3-d282-4cdb-ab18-c92a6041b5a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.