Hi, one possibility is this:
class UserTest(TestCase): def setUp(self): self.my_data = {...} def test_create_account(self): response = self.client.post('/signup/', json.dumps(self.my_data), content_type='application/json') self.assertIs(...) def test_login(self): ... In some cases this will work, but it might also not work (e.g. if you want to organize tests differently). I've found Two Scoops' advice invaluable on this issue: 1) Never use fixtures, 2) DRY does not apply to tests. It's fine to repeat the same code again and again when testing. Regards, A. Antonis Christofides http://djangodeployment.com On 2017-05-23 10:07, Akash Tomar wrote: > class SignUpTest(TestCase): > def test_createAccount(self): > my_data = {'username': 'akash.tomar107', 'password': > 'akashtomar',"email":"akash.tomar...@gmail.com", > "confirm_password":"akashtomar", "type_of_user":"1", "first_name":"akash", > "last_name":"tomar"} > response = self.client.post('/signup/', json.dumps(my_data), > content_type='application/json') > self.assertIs(json.loads(response.content)["success"], True) > > class LoginTest(TestCase): > def test_login(self): > my_data = {'username': 'akash.tomar107', 'password': 'akashtomar'} > response = self.client.post('/login/', json.dumps(my_data), > content_type='application/json') > # import pdb; pdb.set_trace() > self.assertIs(json.loads(response.content)["login"], True) > > > I want to be able to use the data created while running SignUpTest in the > LoginTest. How do I achieve that? Please help. > -- > 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 django-users+unsubscr...@googlegroups.com > <mailto:django-users+unsubscr...@googlegroups.com>. > To post to this group, send email to django-users@googlegroups.com > <mailto:django-users@googlegroups.com>. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/a3625070-4f46-4c68-b912-888b91e42c82%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/a3625070-4f46-4c68-b912-888b91e42c82%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout. -- 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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e78d2dd3-3e47-f90c-6ec0-97aab76d551b%40djangodeployment.com. For more options, visit https://groups.google.com/d/optout.