Django测试的实用程序。
django-test-helper的Python项目详细描述
django测试帮助程序
==django测试帮助程序在测试django应用程序时提供一些实用程序功能
经过身份验证的用户。它接受用户名和密码作为参数。
`` python
来自django.test import testcase
来自test_helper.utils import authenticated_user
来自django.core.urlresolvers import reverse
类mytest(testcase):
def test_protected_view(self):
以autentiated_user('username','pass')作为客户端:
response=client.get(reverse('protected戋view')
self.assertequal(response.status,200)
`````
它需要一个大小元组和一个颜色rgb元组。
`` python
来自django。test import testcase
来自test_helper。utils import image_file
class mytest(testcase):
def test_form(self):
data={
“first戥name”:“john,
“last戥name”:“smith”,
}
image=image_文件(大小=(100,100),
颜色=(128,128,128))
文件={
化身:图像,
}
form=profileform(数据,文件)
self.asserttrue(form.is_valid())
```
==django测试帮助程序在测试django应用程序时提供一些实用程序功能
经过身份验证的用户。它接受用户名和密码作为参数。
`` python
来自django.test import testcase
来自test_helper.utils import authenticated_user
来自django.core.urlresolvers import reverse
类mytest(testcase):
def test_protected_view(self):
以autentiated_user('username','pass')作为客户端:
response=client.get(reverse('protected戋view')
self.assertequal(response.status,200)
`````
它需要一个大小元组和一个颜色rgb元组。
`` python
来自django。test import testcase
来自test_helper。utils import image_file
class mytest(testcase):
def test_form(self):
data={
“first戥name”:“john,
“last戥name”:“smith”,
}
image=image_文件(大小=(100,100),
颜色=(128,128,128))
文件={
化身:图像,
}
form=profileform(数据,文件)
self.asserttrue(form.is_valid())
```