Pyunit源码笔记之六 testcase run的执行前奏
2017-06-01 14:09
633 查看
接上文,
for index, test in enumerate(self)第三次,test就是testcase:
testmul (__main__.MyTest)
testsum (__main__.MyTest)
TestCase.py中的class TestCase(object)的__call__()
result.startTest(self)执行,也调用result.py的def startTest(self, test),testcase计数self.testsRun += 1
<bound method MyTest.testmul of <__main__.MyTest testMethod=testmul>>
<bound method MyTest.testsum of <__main__.MyTest testMethod=testsum>>
self._addSkip(result, self, skip_why)向result中添加skiped cases的信息,也调用result.py的addSkip(self, test, reason),self.skipped是一个list。
下面用class _Outcome(object)来执行和保存执行中的信息
for index, test in enumerate(self)第三次,test就是testcase:
testmul (__main__.MyTest)
testsum (__main__.MyTest)
TestCase.py中的class TestCase(object)的__call__()
def __call__(self, *args, **kwds): return self.run(*args, **kwds)TestCase.py中的class TestCase(object)的def run(self, result=None)
def run(self, result=None): ...... result.startTest(self) testMethod = getattr(self, self._testMethodName) if (getattr(self.__class__, "__unittest_skip__", False) or getattr(testMethod, "__unittest_skip__", False)): # If the class or method was skipped. try: skip_why = (getattr(self.__class__, '__unittest_skip_why__', '') or getattr(testMethod, '__unittest_skip_why__', '')) self._addSkip(result, self, skip_why) finally: result.stopTest(self) return expecting_failure_method = getattr(testMethod, "__unittest_expecting_failure__", False) expecting_failure_class = getattr(self, "__unittest_expecting_failure__", False) expecting_failure = expecting_failure_class or expecting_failure_method 4000 outcome = _Outcome(result) try: self._outcome = outcome
result.startTest(self)执行,也调用result.py的def startTest(self, test),testcase计数self.testsRun += 1
def startTest(self, test): "Called when the given test is about to be run" self.testsRun += 1 self._mirrorOutput = False self._setupStdout()testMethod = getattr(self, self._testMethodName)取得 测试用例方法:
<bound method MyTest.testmul of <__main__.MyTest testMethod=testmul>>
<bound method MyTest.testsum of <__main__.MyTest testMethod=testsum>>
self._addSkip(result, self, skip_why)向result中添加skiped cases的信息,也调用result.py的addSkip(self, test, reason),self.skipped是一个list。
def addSkip(self, test, reason): """Called when a test is skipped.""" self.skipped.append((test, reason))
下面用class _Outcome(object)来执行和保存执行中的信息
class _Outcome(object): def __init__(self, result=None): self.expecting_failure = False self.result = result self.result_supports_subtests = hasattr(result, "addSubTest") self.success = True self.skipped = [] self.expectedFailure = None self.errors = []
相关文章推荐
- Pyunit源码笔记之十一 testCase run之后的 各种result
- Pyunit源码笔记之五 开始执行testsuit的run及迭代
- Pyunit源码笔记之七 testcase正式执行,重点重点重点
- Pyunit源码笔记之九 testsuite执行后,runner/result的结果输出
- Pyunit源码笔记之十一 pyunit运行方式之二:testsuit方式
- Pyunit源码笔记之八 testcase执行后的结果处理
- jquery源码学习笔记:自执行匿名函数剖析
- Pyunit源码笔记之十 pyunit运行方式之一:直接调用
- QUnit源码阅读(2):test基本执行流程
- Run Android Testcase
- How to run keystone testcase against the DB backend other than SQLITE
- 编译caffe源码时,make runtest问题解决方案:[ FAILED ] SGDSolverTest/0.TestSnapshotShare, where TypeParam = caffe:
- MyBatis源码学习笔记(十)SQL执行流程分析
- TestNG入门笔记[4]: testng.xml 执行case —— 参数的传递
- SOAPUI测试步骤(三)---Run TestCase
- Cocos2d-x学习笔记(17)(TestCpp源码分析-1)
- Cocos2d-x学习笔记(20)(TestCpp源码分析-4)
- Pyunit源码笔记之一 典型例子,后面将分析源码
- obs-studio源码阅读笔记:学习obs流程的第一步,test程序
- nginx 源码学习笔记(十七)—— ngx_worker_process_cycle子进程执行