
[英]iterate trough a forms in dictionary passed from view to html in python with jinja
[英]View passed testcases and show log messages in html report when using python html-testrunner??
我刚刚开始使用html-testrunner创建用于python测试的可读报告。 我有两个问题。
1)我想知道是否可以查看通过的测试用例? 当前只有检查错误和失败的选项。
2)是否可以登录HTML报告? 我试图使用记录器,但仅在控制台输出中可见,而在html报告输出中不可见。
import HtmlTestRunner
import unittest
import os
import sys
import logging
logging.basicConfig()
log = logging.getLogger("DummyLogger")
class TestStringMethods(unittest.TestCase):
""" Example test for HtmlRunner. """
def test_upper(self):
""" Test where I put warning inside of it """
log.info('Printing info inside test case')
log.warning('Printing warn inside test case')
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
log.info('Printing info inside test case')
log.warning('Printing warn inside test case')
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
def test_error(self):
""" This test should be marked as error one. """
raise ValueError
def test_fail(self):
""" This test should fail. """
log.info('Printing info inside test case')
log.warning('Printing warn inside test case')
self.assertEqual(1, 2)
@unittest.skip("This is a skipped test.")
def test_skip(self):
""" This test should be skipped. """
pass
if __name__ == '__main__':
logging.basicConfig( stream=sys.stderr )
logging.getLogger( "DummyLogger" ).setLevel( logging.INFO )
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='outputFolder', report_title='Dummy report title test'))
我希望有人可以在这方面帮助我...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.