当前位置 : 主页 > 编程语言 > python >

13 unittest模块

来源:互联网 收集:自由互联 发布时间:2022-06-15
1 # -*- coding: utf-8 -*- 2 # @Time : 2018/2/2 0002 9:52 3 # @Author : wangyafeng 4 # @Email : 5 6 from selenium import webdriver 7 from selenium.webdriver.support import expected_conditions as EC 8 import time 9 import unittest 10 11 12 cl
1 # -*- coding: utf-8 -*-
2 # @Time : 2018/2/2 0002 9:52
3 # @Author : wangyafeng
4 # @Email :
5
6 from selenium import webdriver
7 from selenium.webdriver.support import expected_conditions as EC
8 import time
9 import unittest
10
11
12 class Blog(unittest.TestCase):
13 @classmethod
14 def setUp(self):
15 self.driver = webdriver.Firefox()
16 self.driver.get("http://www.***.com/yoyoketang")
17 print("setUp")
18
19 def test_blog(self):
20 time.sleep(3)
21 result = EC.title_is(u'上海-悠悠 ')(self.driver)
22 print(result)
23 self.assertTrue(result)
24
25 def tearDown(self):
26 self.driver.quit()
27 print("tearDown")
28
29
30 if __name__ == "__main__":
31 unittest.main()
32 '''
33 1).assertEqual(self, first, second,msg=None)
34 --判断两个参数相等:first == second
35 2).assertNotEqual(self, first, second,msg=None)
36 --判断两个参数不相等:first != second
37 3).assertIn(self, member, container,msg=None)
38 --判断是字符串是否包含:member in container
39 4).assertNotIn(self, member,container, msg=None)
40 --判断是字符串是否不包含:member not in container
41 5).assertTrue(self, expr, msg=None)
42 6).assertFalse(self, expr, msg=None)
43 --判断是否为假:expr is False
44 7).assertIsNone(self, obj, msg=None)
45 --判断是否为None:objis None
46 8).assertIsNotNone(self, obj,msg=None)
47 --判断是否不为None:obj is not None
48
49 '''

 


上一篇:Python多版本管理器pyenv
下一篇:没有了
网友评论