本文整理汇总了Python中django.test.testcases.TestCase.setUp方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.setUp方法的具体用法?Python TestCase.setUp怎么用?Python TestCase.setUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.test.testcases.TestCase
的用法示例。
在下文中一共展示了TestCase.setUp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from django.test.testcases import TestCase [as 别名]
# 或者: from django.test.testcases.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
self.bogus_user = bogus_user = get_user_model().objects.get(
username='bogus')
self.bogus_user2 = bogus_user2 = get_user_model().objects.get(
username='bogus2')
# start by resetting the feeds
for u in [self.bogus_user, self.bogus_user2]:
user_feed = feedly.get_user_feed(u.id)
user_feed.delete()
for name, feed in feedly.get_feeds(u.id).items():
feed.delete()
# login the user
rf = RequestMock()
self.rf = rf
self.client = Client()
self.auth_client = Client()
self.auth_client2 = Client()
auth_response = self.auth_client.login(
username='bogus', password='bogus')
self.assertTrue(auth_response)
auth_response = self.auth_client2.login(
username='bogus2', password='bogus')
self.assertTrue(auth_response)
示例2: setUp
# 需要导入模块: from django.test.testcases import TestCase [as 别名]
# 或者: from django.test.testcases.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
self.rule = RuleFactory()
self.rule.active = False
self.rule.save()
self.date = datetime.date(2012, 10, 29)
self.appointment = AppointmentFactory.create(calendar__car=self.rule.car,
calendar__timeslot=self.rule.timeslot)
示例3: setUp
# 需要导入模块: from django.test.testcases import TestCase [as 别名]
# 或者: from django.test.testcases.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
from core.models import Item
print(Item.objects.all().count())
self.client = Client()
self.auth_client = Client()
response = self.auth_client.login(username='admin', password='admin')
self.assertTrue(response)
self.admin = get_user_model().objects.get(username='admin')
self.bogus = get_user_model().objects.get(username='bogus')
示例4: setUp
# 需要导入模块: from django.test.testcases import TestCase [as 别名]
# 或者: from django.test.testcases.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
self.user = User.objects.create_superuser('eytan', '[email protected]', 'test')
login_successful = self.client.login(username="eytan",password="test")
self.assertTrue(login_successful)
示例5: setUp
# 需要导入模块: from django.test.testcases import TestCase [as 别名]
# 或者: from django.test.testcases.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
示例6: setUp
# 需要导入模块: from django.test.testcases import TestCase [as 别名]
# 或者: from django.test.testcases.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
self.sett = self.settings(**SETTINGS)
self.sett.enable()
assert self.client.login(username='sax', password='123')