当前位置:网站首页>Unittest attempt
Unittest attempt
2022-07-03 06:33:00 【Bobo AI leaves work】
1. Inheritance class
import unittest
class TestApi(unittest.TestCase):
def test_01_login(self):
print(" Test landing ")
def test_02_login(self):
print(" Test registration ")
2. Usage of test suite unittest.main(defaultTest="suite")
import unittest
from test_apis.test_api import TestApi
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(TestApi("test_01_login"))
# Add a set of test cases
testcases=[TestApi("test_01_login"),TestApi("test_02_login")]
suite.addTests(testcases)
unittest.main(defaultTest="suite")
3. Through the loader TestLoader load
import unittest
from test_apis.test_api import TestApi
if __name__ == '__main__':
suite=unittest.defaultTestLoader.discover("./",pattern="test_*.py")
unittest.main(defaultTest="suite")
Assert whether the titles are equal :
import unittest
from selenium import webdriver
class Test_Bai(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
driver=webdriver.Chrome()
driver.get("http://www.baidu.com")
title=driver.title
print(title)
return title
def test_assert_title(self):
self.assertEqual(self.setUpClass()," use Baidu Search , You will know ")
if __name__ == '__main__':
unittest.main
边栏推荐
猜你喜欢

The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list

Use selenium to climb the annual box office of Yien

论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》

Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide

IE browser flash back, automatically open edge browser

YOLOV1学习笔记

远端rostopic的本地rviz调用及显示

表达式的动态解析和计算,Flee用起来真香

Selenium - 改变窗口大小,不同机型呈现的宽高长度会不一样

2022 cisp-pte (III) command execution
随机推荐
使用conda创建自己的深度学习环境
Yolov2 learning and summary
剖析虚幻渲染体系(16)- 图形驱动的秘密
Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
[set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
Push box games C #
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
Oauth2.0 - use database to store client information and authorization code
Svn branch management
Mysql5.7 group by error
YOLOV2学习与总结
Zhiniu stock -- 03
Selenium - by changing the window size, the width, height and length of different models will be different
【开源项目推荐-ColugoMum】这群本科生基于国产深度学习框架PaddlePadddle开源了零售行业解决方案
【LeetCode】Day93-两个数组的交集 II
Introduction to software engineering
Chapter 8. MapReduce production experience
Create your own deep learning environment with CONDA
Zhiniu stock project -- 05
Mysql database binlog log enable record