##################初始化###################### # g = {} # def setup_module(module): # print "单元测试开始" # g = { # 'email':123 # } # def test_abc(): # print g['a'] # assert g['a']==1 ##################UserDao########################## email = StringUtil.token_generator() + "@qq.com" user_name = 'xiaolin' pwd = 'zxldmv' enroll_type='email' ''' 用户注册流程 ''' def test_register(): result = UserDao.register(email, enroll_type,user_name, pwd) assert result == 'success' def test_get_user_by_email(): user = UserDao.get_user_by_email(email) assert user['email'] == email def test_get_user_by_tid():
import urllib import urllib2 import cookielib from dao import UserDao #生成随机电话号码 def random_tel(): tel_list = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'] tel_start = ['13','15','14','18'] b = string.join(random.sample(tel_list,9)).replace(" ","") a = random.choice(tel_start) tel = a+b return tel tel = random_tel() email = StringUtil.token_generator() + '@qq.com' #随机选取注册方式:手机|邮箱 def random_email_or_phone(): random_dict = { '0':tel, '1':email } random_key = random.choice(random_dict.keys()) random_value = random_dict[random_key] return random_value def UniversalTest_post(postData,url): postData = urllib.urlencode(postData) request = urllib2.Request(