I have a test class where I would like to create and login a user once:
class UserModelTest(TestCase):
fixtures = ['group_perms']
@classmethod
def setUpClass(cls):
cls.standard_user = UserFactory(first_name='Firsto', last_name='Namo')
@classmethod
def tearDownClass(cls):
cls.standard_user.delete()
def setUp(self):
self.moderator = ModeratorFactory() # I'm here because I need access to fixtures to work - but I'd rather be in setUpClass
self.client.login(email=self.moderator.email, pass='pass') # I'm here because I need access to self.client to work - but I'd rather be in setUpClass
So my question (or two):
Can I move the moderator into the
setUpClass
method (given it needs access to fixtures)?Can I access
self.client
insetUpClass
?
Aucun commentaire:
Enregistrer un commentaire