为什么如果我python manage.py test appname
在终端中运行是: Ran 0 tests in 0.000s OK
这是我的tests.py:
from django.test import TestCase
import appname.factories
class UserProfileTest(TestCase):
def sample_data(self):
for i in range(0, 10):
user = appname.factories.UserProfileFactory.create()
我的模型.py:
from django.db import models
class UserProfile(models.Model):
street = models.CharField(max_length=250)
tel = models.CharField(max_length=64, default='', blank=True)
postcode = models.CharField(max_length=250)
def __unicode__(self):
return self.tel
我的 factory.py(工厂男孩):
from appname.models import *
import factory
class UserProfileFactory(factory.Factory):
FACTORY_FOR = UserProfile
street = factory.Sequence(lambda n: 'Street' + n)
tel = factory.Sequence(lambda n: 'Tel' + n)
password = 'abcdef'