0
我正在编写烧瓶Web应用程序的测试,并且每个测试都需要用户登录 是否有任何方法来定义测试功能并将其用于其他测试? 这是我目前的TestCase的,我想实现登录功能,只使用后向API URL测试需要登录烧瓶应用程序
class TestLogin(unittest.TestCase):
def setUp(self):
self.headers = {'Content-type':'application/json','Accept':'tex/plain')
def test_login(self):
s=request.Session()
url = 'http://localhost/api/v1/user/login/'
data = {'username' = 'admin','password' :'123123'}
r=s.post(url,data=json.dumps(data),headers=self.headers)
self.assertEqual(r.status_code,200)
我怎么可以节省使用其他测试未来会议? – shalbafzadeh 2015-02-05 16:06:58