Skip to content

Instantly share code, notes, and snippets.

@steve-chavez
Last active August 29, 2015 14:05
Show Gist options
  • Save steve-chavez/a33f2d43a6bb2aedd707 to your computer and use it in GitHub Desktop.
Save steve-chavez/a33f2d43a6bb2aedd707 to your computer and use it in GitHub Desktop.
Django one time setup in test
from django.test import TestCase
from django.contrib.auth.models import User
from payments.models import Customer
# To allow test setup run only one time these workaround can be used
class CustomerModelTest(TestCase):
@classmethod
def setUpClass(cls):
cls.user = User.objects.create_user(username="test@est.com",
email="test@test.com",
password="12345",
first_name="Test",
last_name="Test")
cls.customer = Customer.create(cls.user)
def test_something(self):
pass
def test_other_thing(self):
pass
##Create user is only called one time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment