Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of HTML Test report in python

Shulou Source: shulou.com Published: 2022-06-03 17:34:18 10月05日 Update

This article mainly shows you the "sample analysis of HTML test reports in python", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let me lead you to study and study the "sample analysis of HTML test reports in python".

Description

1. Copy the file to the project directory.

2. Import the module into the code.

From HTMLTestRunner import HTMLTestRunner

3. Call HTMLTestRunner.

(stream=file, title = my first html test report)

4. Open the file with open.

The open file name extension must be .html.

5. Use wb when opening files.

There is no need to specify a character set.

6. Execute the test suite.

Call the run method of the runner object

7. Close the file that opens open.

Example

Import unittestfrom HTMLTestRunner import HTMLTestRunner# uses the discover method of the TestLoader object to automatically find py, and automatically loads the method # in the py file. The first parameter is where to find the py file, "." Find the py file from the current directory # the second parameter is to specify the file name of the py file. You can use the wildcard character suite = unittest.TestLoader () .discover (".", "my*.py") # runner = unittest.TextTestRunner () file = open ("test01.html", "wb") # open the file # runner = unittest.TextTestRunner (stream=file, verbosity=2) runner = HTMLTestRunner (stream=file) in binary writing with wb. Title= "my first html test report") runner.run (suite) file.close () # demo08 module (demo08.py file) import unittestfrom parameterized import parameterized def digital (str1): sum = 0 for n in str1: if n > ='0' and n

Tags: Files tests reports parameters methods examples analysis hello content modules articles functions characters objects directories not for learning help generation binary Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple OPPO Reno NVidia Linux vpn