pytest.mark.parametrize()參數化應用二,讀取json文件


 1 class TestEnorll():
 2 
 3     def get_data(self):
 4         """
 5         讀取json文件
 6         :return:
 7         """
 8         data = []
 9         with open(self, 'r') as f:
10             dict_data = json.loads(f.read())
11             for i in dict_data:
12                 data.append(tuple(i.values()))
13         return data
14 
15     @pytest.mark.parametrize(
16         "name, email, pwd, pwd_",
17         get_data(BASE_DIR + '\\data' + '\\enorlluser.json'),
18         ids=['注冊成功', '密碼不一致', '會員輸入框為空', '重名注冊', '電子郵箱為空', '電子郵箱錯誤', '密碼輸入框為空']
19     )
20     def test_case(self, browser, name, email, pwd, pwd_, url=None):
21         obj = Enorllpage(browser)
22         pass
View Code

.json結尾的文件.......


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM