Reputation: 3293
I want to setup django test data for all app unit tests, like create a user before all tests running, and then the test in each app test could use that user.
Upvotes: 0
Views: 306
Reputation: 1120
Why not generating a base class for all your tests that do need this user. Create it in the setUp Method of that Class or use an fixture in this base class
eg. like this :
class ViewMethodsTestCase(TestCase):
fixtures = ['initial_data.json']
def setUp(self):
self.user = ShrUser.objects.create_user(username="lala",
password="lala", email="lala0@localhost")
loggedIn = self.client.login(username="lala", password="lala")
self.assertTrue(loggedIn, "not logged in")
Upvotes: 1