当前位置:网站首页>Unittest unit test (IV)
Unittest unit test (IV)
2022-04-21 13:48:00 【Effort volume】
( Continuation of the previous section ) Underlying logic code
TestCase The test case : The smallest unit , Business logic
TestSuite test suite : A collection of test cases , Or a collection of test suites
def createTests(self, from_discovery=False, Loader=None):
if self.testNamePatterns:
self.testLoader.testNamePatterns = self.testNamePatterns
if from_discovery:
loader = self.testLoader if Loader is None else Loader()
self.test = loader.discover(self.start, self.pattern, self.top)
elif self.testNames is None:
self.test = self.testLoader.loadTestsFromModule(self.module)
else:
self.test = self.testLoader.loadTestsFromNames(self.testNames,
self.module)
TestFixtrue Test fixture : Perform the actions before and after the test case
TestLoader Test loader : Load test cases
def __init__(self, module='__main__', defaultTest=None, argv=None,
testRunner=None, testLoader=loader.defaultTestLoader,
exit=True, verbosity=1, failfast=None, catchbreak=None,
buffer=None, warnings=None, *, tb_locals=False):
TestRunner Test runner : Run the specified test case
def runTests(self):
if self.catchbreak:
installHandler()
if self.testRunner is None:
self.testRunner = runner.TextTestRunner
if isinstance(self.testRunner, type):
try:
try:
testRunner = self.testRunner(verbosity=self.verbosity,
failfast=self.failfast,
buffer=self.buffer,
warnings=self.warnings,
tb_locals=self.tb_locals)
except TypeError:
# didn't accept the tb_locals argument
testRunner = self.testRunner(verbosity=self.verbosity,
failfast=self.failfast,
buffer=self.buffer,
warnings=self.warnings)
except TypeError:
# didn't accept the verbosity, buffer or failfast arguments
testRunner = self.testRunner()
else:
# it is assumed to be a TestRunner instance
testRunner = self.testRunner
self.result = testRunner.run(self.test)
if self.exit:
sys.exit(not self.result.wasSuccessful())
A brief analysis of the principle :
if __name__ == '__main__':
suite = unittest.defaultTestLoader.discover('./test', pattern='*.py')
unittest.TextTestRunner().run(suite)
版权声明
本文为[Effort volume]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211347166920.html
边栏推荐
- Locate the structural pseudo class of the child element
- MySQL学习笔记-day03
- 关于`Object.clone()`子类不能调用的思考
- 并发编程之CAS和Atomic原子操作类
- 机器学习笔记 - SVD奇异值分解(3) 在图像上应用 SVD
- SQLyog导入sql文件
- Character sorting in the string (10 points): please write the function fun to sort the strings with a length of 8 characters in descending order.
- 字符串串动变化 (10 分)下列程序中,函数fun的功能是:在字符串str中找出ASCII码值最大的字符,将该字符前的所有字符向后顺序移动一个位置,然后将该字符放到第一个位置上。
- Benchmark cell detection scheme based on violence matching threshold
- Beauty of ASM pile insertion
猜你喜欢

专家系统实例及其骨架系统

EsgynDB 清理不一致对象

JVM字节码文件结构深度剖析

Machine learning notes - Moore Penrose pseudo inverse

Metasploit penetration

In office word 2016, omml2mml appears when the formula edited by word's own formula editor is transferred to MathType Solutions to XSL problems

【leetcode】144.二叉树的前序遍历

The sales attribute values in sku must be filled in in pairs. Why

Machine learning notes - SVD singular value decomposition (3) applying SVD to images

Idea automatically generates unit test classes
随机推荐
做自媒体、短视频,不用自己拍视频,大周教你一个快速起号的方法
JVM內存分配機制詳解
How to recover if U disk data is lost? U disk data recovery, two schemes completed
Idea automatically generates unit test classes
echart常见的配置项(线、区域、文本)
Feedforward neural network
关于`Object.clone()`子类不能调用的思考
Tool function - date formatting
List stores map values
机器学习笔记 - SVD奇异值分解(3) 在图像上应用 SVD
【leetcode】144.二叉树的前序遍历
软件工程-基础篇刷题
工具函数---日期格式化
Programmers burst out their salary, with a monthly salary of 15000 before tax
String string dynamic change (10 points): in the following procedures, the function of fun is to find the character with the largest ASCII code value in the string STR, move all the characters before
u盘数据丢失了怎么恢复?u盘数据恢复,2个方案完成
Open mmlab / mmpose installation and use tutorial
Peking University ACM problems 1010: stamps
Nmap usage
nmap使用