问题:
selenium导入unittest框架和HtmlReport框架后,HtmlReport不被执行。
假设代码为:
from selenium import webdriver
import unittest
class Test(unittest.TestCase):
print "this is class Test"
def setup(self):
print "this is setup"
def test_1(self):
print "this is tesecase 1"
#其他代码
def tearDown(self):
print "this is tearDown"
if __name__ == ‘__main__‘:
print "this is __name__"
#unittest.main()
网上搜索到的资料:
1、Pycharm运行导入unittest框架时,执行的的命令是“Run ‘Unittests in XXX‘ ”,如下图所示:
2、此时执行顺序为:Class->def setup ->def test_1 ->def tearDown
3、如果执行的命令为“Run XXX”,那么会先执行class后,就执行“if __name__ == ‘__main__‘ ”
参考资料:
http://www.ithao123.cn/content-6035445.html
python unittest不执行"if __name__ == '__main__' "问题
时间: 2024-10-06 13:57:19