本文整理汇总了Python中django.test.testcases.TestCase类的典型用法代码示例。如果您正苦于以下问题:Python TestCase类的具体用法?Python TestCase怎么用?Python TestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestCase类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
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: assertDictContainsSubset
def assertDictContainsSubset(self, a, b, *args):
try:
DjangoTestCase.assertDictContainsSubset(self, a, b, *args)
except AttributeError:
for key, value in a.items():
self.assertTrue(key in b)
self.assertEqual(b[key], value)
示例3: setUp
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)
示例4: setUp
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')
示例5: assertIn
def assertIn(self, expected, source, *args):
try:
DjangoTestCase.assertIn(self, expected, source, *args)
except AttributeError:
self.assertTrue(expected in source)
示例6: setUp
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)
示例7: setUp
def setUp(self):
TestCase.setUp(self)
示例8: __init__
def __init__(self):
TestCase.__init__(self, methodName='stop')
示例9: setUp
def setUp(self):
TestCase.setUp(self)
self.sett = self.settings(**SETTINGS)
self.sett.enable()
assert self.client.login(username='sax', password='123')
示例10: __init__
def __init__(self, method_name):
self.ciprofloxacin = None
TestCase.__init__(self, method_name)