#HTMLTestRunner code modifications refer to a slight smile, the following is the link, this has been said in detail
Https://www.cnblogs.com/miniren/p/5301081.html
(i) Preface
UnitTest output test results on the command line. You may need to generate an execution result for all tests as a report or send the test results to the relevant person. Sending command-line logs to related people is not a sensible choice. They need a more user-friendly test report that allows them to see a summary of the test results and to drill down into the details of the report.
(ii) generate test reports using Htmltestrunner
Htmltestrunner is an extension of UnitTest written by Wai Yip Tung.
http://tungwaiyip.info/software/HTMLTestRunner.html download code
(click htmltestrunner.py, then copy it directly)
After the modified code htmltestrunner.py, I put it in the lib\site-packages directory of the Python installation directory
(iii) smoketests.py
import unittest
import htmltestrunner
Import os
from searchtest import searchtest
from Homepagetest Import homepagetest
dir = os.getcwd ()
# Gets the Searchtest class and All test methods in the Homepagetest class
search_test =unittest. Testloader (). Loadtestsfromtestcase (searchtest)
Home_page_test = UnitTest. Testloader (). Loadtestsfromtestcase (homepagetest)
# Create a test suite that includes Searchtest and Homepagetest
Smoke_tests =unittest. TestSuite ([home_page_test,search_test])
# opens the file in binary form for writing
outfile = open (dir+ "\ Smoketestreport.html ", " WB ")
# config htmltestrunner
runner = Htmltestrunner.htmltestrunner (stream=outfile,title= ' Test report ' , description= ' Smoketests ' )
# run test suite via Htmltestrunner
runner.run (smoke_tests)
(iv) run smoketests.py to generate test reports
Htmltestrunner runs all tests like the default test executor for UnitTest. At the end of the use case execution, it will generate a test report file, as shown in.
(v) Notes 1 to 5 all sample code
Https://pan.baidu.com/s/1qZJHuyS
Python+selenium Note (v): Generate test Report