python3.x安装HTMLTestRunner和使用

这篇具有很好参考价值的文章主要介绍了python3.x安装HTMLTestRunner和使用。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

笔者:风起怨江南 出处:https://www.cnblogs.com/mengjinxiang 笔者原创,文章欢迎转载,如果喜欢请点赞+关注,感谢支持!

前言:最近一直在其他博客论坛上写Python的相关技术博客->https://blog.csdn.net/JackMengJin,计划还是在博客园上写一些关于安装、排错、爬坑等等一些零散的技术点,这样感觉好一点(轻微强迫症患者= =)。

操作:

1.什么是HTMLTestRunner?

在网上(包括在Python官方文库)找不到HTMLTestRunner相关解释资料。其实HTMLTestRunner是一个第三方的unittest HTML报告库,关于unittest在Python官方文库上很容易找到:https://docs.python.org/zh-cn/3.7/library/unittest.html#assert-methods,下面是截取的部分说明:

unittest 单元测试框架是受到 JUnit 的启发,与其他语言中的主流单元测试框架有着相似的风格。其支持测试自动化,配置共享和关机代码测试。支持将测试样例聚合到测试集中,并将测试与报告框架独立。

为了实现这些,unittest 通过面向对象的方式支持了一些重要的概念。

测试脚手架

test fixture 表示为了开展一项或多项测试所需要进行的准备工作,以及所有相关的清理操作。举个例子,这可能包含创建临时或代理的数据库、目录,再或者启动一个服务器进程。

测试用例

一个测试用例是一个独立的测试单元。它检查输入特定的数据时的响应。 unittest 提供一个基类: TestCase ,用于新建测试用例。

测试套件

test suite 是一系列的测试用例,或测试套件,或两者皆有。它用于归档需要一起执行的测试。

测试运行器(test runner)

test runner 是一个用于执行和输出测试结果的组件。这个运行器可能使用图形接口、文本接口,或返回一个特定的值表示运行测试的结果。

unittest 模块提供了一系列创建和运行测试的工具。这一段落演示了这些工具的一小部分,但也足以满足大部分用户的需求。

这是一段简短的代码,来测试三种字符串方法:

复制代码
import unittest

class TestStringMethods(unittest.TestCase):

def test_upper(self):
    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'])
    # check that s.split fails when the separator is not a string
    with self.assertRaises(TypeError):
        s.split(2)

if name == ‘main’:
unittest.main()
复制代码

通过以上资料可以看到unittest能够输出txt格式的文本执行报告,但是文本报告太过简陋,是不是想要更加高大上的HTML报告?

但unittest自己可没有带HTML报告,我们只能求助于外部的库了——HTMLTestRunner.py。

2.下载HTMLTestRunner.py

为什么是下载HTMLTestRunner.py而不直接是HTMLTestRunner呢?

揭晓答案前我们先用常规手段下载HTMLTestRunner:

通过Pycharm下载HTMLTestRunner

确保使用的是豆瓣源下载后,点击安装:

果然报错…,为什么会报错呢?

通过pip下载HTMLTestRunner
这里我再尝试下使用pip下载:

结果发现不管怎么尝试,都是不行:)

于是我查了下资料,得到了一个结论:原因其实就是HTMLTestRunner是Python标准库的unittest模块的扩展,无法通过pip安装。

那么我们要怎么使用和下载HTMLTestRunner呢?

其实解决方法很简单,需要通过手动下载HTMLTestRunner.py文件,放在python目录Lib文件夹下即可:

由于当前Python2.x绝大多数情况下不再使用,这里之将支持Python3.x的HTMLTestRunner.py文件放上来:

复制代码
“”"
A TestRunner for use with the Python unit testing framework. It
generates a HTML report to show the result at a glance.

The simplest way to use this is to invoke its main method. E.g.

import unittest
import HTMLTestRunner

... define your tests ...

if __name__ == '__main__':
    HTMLTestRunner.main()

For more customization options, instantiates a HTMLTestRunner object.
HTMLTestRunner is a counterpart to unittest’s TextTestRunner. E.g.

# output to a file
fp = file('my_report.html', 'wb')
runner = HTMLTestRunner.HTMLTestRunner(
            stream=fp,
            title='My unit test',
            description='This demonstrates the report output by HTMLTestRunner.'
            )

# Use an external stylesheet.
# See the Template_mixin class for more customizable options
runner.STYLESHEET_TMPL = '<link rel="stylesheet" href="my_stylesheet.css" type="text/css">'

# run the test
runner.run(my_test_suite)

Copyright © 2004-2007, Wai Yip Tung
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

  • Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
  • Neither the name Wai Yip Tung nor the names of its contributors may be
    used to endorse or promote products derived from this software without
    specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS
IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
“”"

URL: http://tungwaiyip.info/software/HTMLTestRunner.html

author = “Wai Yip Tung”
version = “0.8.2”

“”"
Change History

Version 0.8.2

  • Show output inline instead of popup window (Viorel Lupu).

Version in 0.8.1

  • Validated XHTML (Wolfgang Borgert).
  • Added description of test classes and test cases.

Version in 0.8.0

  • Define Template_mixin class for customization.
  • Workaround a IE 6 bug that it does not treat

Version in 0.7.1

  • Back port to Python 2.3 (Frank Horowitz).
  • Fix missing scroll bars in detail log (Podi).
    “”"

TODO: color stderr

TODO: simplify javascript using ,ore than 1 class in the class attribute?

import datetime
#2.7版本为 import StringIO
import io
import sys
import time
import unittest
from xml.sax import saxutils

------------------------------------------------------------------------

The redirectors below are used to capture output during testing. Output

sent to sys.stdout and sys.stderr are automatically captured. However

in some cases sys.stdout is already cached before HTMLTestRunner is

invoked (e.g. calling logging.basicConfig). In order to capture those

output, use the redirectors for the cached stream.

e.g.

>>> logging.basicConfig(stream=HTMLTestRunner.stdout_redirector)

>>>

class OutputRedirector(object):
“”" Wrapper to redirect stdout or stderr “”"
def init(self, fp):
self.fp = fp

def write(self, s):
    self.fp.write(s)

def writelines(self, lines):
    self.fp.writelines(lines)

def flush(self):
    self.fp.flush()

stdout_redirector = OutputRedirector(sys.stdout)
stderr_redirector = OutputRedirector(sys.stderr)

----------------------------------------------------------------------

Template

class Template_mixin(object):
“”"
Define a HTML template for report customerization and generation.

Overall structure of an HTML report

HTML
+------------------------+
|<html>                  |
|  <head>                |
|                        |
|   STYLESHEET           |
|   +----------------+   |
|   |                |   |
|   +----------------+   |
|                        |
|  </head>               |
|                        |
|  <body>                |
|                        |
|   HEADING              |
|   +----------------+   |
|   |                |   |
|   +----------------+   |
|                        |
|   REPORT               |
|   +----------------+   |
|   |                |   |
|   +----------------+   |
|                        |
|   ENDING               |
|   +----------------+   |
|   |                |   |
|   +----------------+   |
|                        |
|  </body>               |
|</html>                 |
+------------------------+
"""

STATUS = {
0: 'pass',
1: 'fail',
2: 'error',
}

DEFAULT_TITLE = 'Unit Test Report'
DEFAULT_DESCRIPTION = ''

# ------------------------------------------------------------------------
# HTML Template

HTML_TMPL = r"""<?xml version="1.0" encoding="UTF-8"?>
%(title)s %(stylesheet)s

/* level - 0:Summary; 1:Failed; 2:All */
function showCase(level) {
trs = document.getElementsByTagName(“tr”);
for (var i = 0; i < trs.length; i++) {
tr = trs[i];
id = tr.id;
if (id.substr(0,2) == ‘ft’) {
if (level < 1) {
tr.className = ‘hiddenRow’;
}
else {
tr.className = ‘’;
}
}
if (id.substr(0,2) == ‘pt’) {
if (level > 1) {
tr.className = ‘’;
}
else {
tr.className = ‘hiddenRow’;
}
}
}
}

function showClassDetail(cid, count) {
var id_list = Array(count);
var toHide = 1;
for (var i = 0; i < count; i++) {
tid0 = ‘t’ + cid.substr(1) + ‘.’ + (i+1);
tid = ‘f’ + tid0;
tr = document.getElementById(tid);
if (!tr) {
tid = ‘p’ + tid0;
tr = document.getElementById(tid);
}
id_list[i] = tid;
if (tr.className) {
toHide = 0;
}
}
for (var i = 0; i < count; i++) {
tid = id_list[i];
if (toHide) {
document.getElementById(‘div_’+tid).style.display = ‘none’
document.getElementById(tid).className = ‘hiddenRow’;
}
else {
document.getElementById(tid).className = ‘’;
}
}
}

function showTestDetail(div_id){
var details_div = document.getElementById(div_id)
var displayState = details_div.style.display
// alert(displayState)
if (displayState != ‘block’ ) {
displayState = ‘block’
details_div.style.display = ‘block’
}
else {
details_div.style.display = ‘none’
}
}

function html_escape(s) {
s = s.replace(/&/g,‘&’);
s = s.replace(/</g,‘<’);
s = s.replace(/>/g,‘>’);
return s;
}

/* obsoleted by detail in


function showOutput(id, name) {
var w = window.open(“”, //url
name,
“resizable,scrollbars,status,width=800,height=450”);
d = w.document;
d.write(“
”);
d.write(html_escape(output_list[id]));
d.write(“\n”);
d.write(“close\n”);
d.write(“
\n”);
d.close();
}
*/
–>

%(heading)s
%(report)s
%(ending)s

""" # variables: (title, generator, stylesheet, heading, report, ending)
# ------------------------------------------------------------------------
# Stylesheet
#
# alternatively use a <link> for external style sheet, e.g.
#   <link rel="stylesheet" href="$url" type="text/css">

STYLESHEET_TMPL = """

“”"

# ------------------------------------------------------------------------
# Heading
#

HEADING_TMPL = """<div class='heading'>

%(title)s

%(parameters)s

%(description)s

“”" # variables: (title, parameters, description)

HEADING_ATTRIBUTE_TMPL = """<p class='attribute'><strong>%(name)s:</strong> %(value)s</p>

“”" # variables: (name, value)

# ------------------------------------------------------------------------
# Report
#

REPORT_TMPL = """

Show Summary Failed All

%(test_list)s
Test Group/Test case Count Pass Fail Error View
Total %(count)s %(Pass)s %(fail)s %(error)s  
""" # variables: (test_list, count, Pass, fail, error)
REPORT_CLASS_TMPL = r"""
%(desc)s %(count)s %(Pass)s %(fail)s %(error)s Detail """ # variables: (style, desc, count, Pass, fail, error, cid)
REPORT_TEST_WITH_OUTPUT_TMPL = r"""
%(desc)s
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_%(tid)s')" >
    %(status)s</a>

<div id='div_%(tid)s' class="popup_window">
    <div style='text-align: right; color:red;cursor:pointer'>
    <a onfocus='this.blur();' onclick="document.getElementById('div_%(tid)s').style.display = 'none' " >
       [x]</a>
    </div>
    <pre>
    %(script)s
    </pre>
</div>
<!--css div popup end-->

</td>
""" # variables: (tid, Class, style, desc, status)
REPORT_TEST_NO_OUTPUT_TMPL = r"""
%(desc)s
%(status)s """ # variables: (tid, Class, style, desc, status)
REPORT_TEST_OUTPUT_TMPL = r"""

%(id)s: %(output)s
“”" # variables: (id, output)

# ------------------------------------------------------------------------
# ENDING
#

ENDING_TMPL = """<div id='ending'>&nbsp;</div>"""

-------------------- The end of the Template class -------------------

TestResult = unittest.TestResult

class _TestResult(TestResult):
# note: _TestResult is a pure representation of results.
# It lacks the output and reporting ability compares to unittest._TextTestResult.

def __init__(self, verbosity=1):
    TestResult.__init__(self)
    self.stdout0 = None
    self.stderr0 = None
    self.success_count = 0
    self.failure_count = 0
    self.error_count = 0
    self.verbosity = verbosity

    # result is a list of result in 4 tuple
    # (
    #   result code (0: success; 1: fail; 2: error),
    #   TestCase object,
    #   Test output (byte string),
    #   stack trace,
    # )
    self.result = []


def startTest(self, test):
    TestResult.startTest(self, test)
    # just one buffer for both stdout and stderr
    # 2.7版本为 self.outputBuffer = StringIO.StringIO()
    self.outputBuffer = io.StringIO()
    stdout_redirector.fp = self.outputBuffer
    stderr_redirector.fp = self.outputBuffer
    self.stdout0 = sys.stdout
    self.stderr0 = sys.stderr
    sys.stdout = stdout_redirector
    sys.stderr = stderr_redirector


def complete_output(self):
    """
    Disconnect output redirection and return buffer.
    Safe to call multiple times.
    """
    if self.stdout0:
        sys.stdout = self.stdout0
        sys.stderr = self.stderr0
        self.stdout0 = None
        self.stderr0 = None
    return self.outputBuffer.getvalue()


def stopTest(self, test):
    # Usually one of addSuccess, addError or addFailure would have been called.
    # But there are some path in unittest that would bypass this.
    # We must disconnect stdout in stopTest(), which is guaranteed to be called.
    self.complete_output()


def addSuccess(self, test):
    self.success_count += 1
    TestResult.addSuccess(self, test)
    output = self.complete_output()
    self.result.append((0, test, output, ''))
    if self.verbosity > 1:
        sys.stderr.write('ok ')
        sys.stderr.write(str(test))
        sys.stderr.write('\n')
    else:
        sys.stderr.write('.')

def addError(self, test, err):
    self.error_count += 1
    TestResult.addError(self, test, err)
    _, _exc_str = self.errors[-1]
    output = self.complete_output()
    self.result.append((2, test, output, _exc_str))
    if self.verbosity > 1:
        sys.stderr.write('E  ')
        sys.stderr.write(str(test))
        sys.stderr.write('\n')
    else:
        sys.stderr.write('E')

def addFailure(self, test, err):
    self.failure_count += 1
    TestResult.addFailure(self, test, err)
    _, _exc_str = self.failures[-1]
    output = self.complete_output()
    self.result.append((1, test, output, _exc_str))
    if self.verbosity > 1:
        sys.stderr.write('F  ')
        sys.stderr.write(str(test))
        sys.stderr.write('\n')
    else:
        sys.stderr.write('F')

class HTMLTestRunner(Template_mixin):
“”"
“”"
def init(self, stream=sys.stdout, verbosity=1, title=None, description=None):
self.stream = stream
self.verbosity = verbosity
if title is None:
self.title = self.DEFAULT_TITLE
else:
self.title = title
if description is None:
self.description = self.DEFAULT_DESCRIPTION
else:
self.description = description

    self.startTime = datetime.datetime.now()


def run(self, test):
    "Run the given test case or test suite."
    result = _TestResult(self.verbosity)
    test(result)
    self.stopTime = datetime.datetime.now()
    self.generateReport(test, result)
    print(sys.stderr,'\nTime Elapsed=%s' %(self.stopTime-self.startTime))
    #2.7版本 print >>sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime)
    return result



def sortResult(self, result_list):
    # unittest does not seems to run in any particular order.
    # Here at least we want to group them together by class.
    rmap = {}
    classes = []
    for n,t,o,e in result_list:
        cls = t.__class__
        # 2.7版本 if not rmap.has_key(cls)
        if not cls in rmap:
            rmap[cls] = []
            classes.append(cls)
        rmap[cls].append((n,t,o,e))
    r = [(cls, rmap[cls]) for cls in classes]
    return r


def getReportAttributes(self, result):
    """
    Return report attributes as a list of (name, value).
    Override this to add custom attributes.
    """
    startTime = str(self.startTime)[:19]
    duration = str(self.stopTime - self.startTime)
    status = []
    if result.success_count: status.append('Pass %s'    % result.success_count)
    if result.failure_count: status.append('Failure %s' % result.failure_count)
    if result.error_count:   status.append('Error %s'   % result.error_count  )
    if status:
        status = ' '.join(status)
    else:
        status = 'none'
    return [
        ('Start Time', startTime),
        ('Duration', duration),
        ('Status', status),
    ]


def generateReport(self, test, result):
    report_attrs = self.getReportAttributes(result)
    generator = 'HTMLTestRunner %s' % __version__
    stylesheet = self._generate_stylesheet()
    heading = self._generate_heading(report_attrs)
    report = self._generate_report(result)
    ending = self._generate_ending()
    output = self.HTML_TMPL % dict(
        title = saxutils.escape(self.title),
        generator = generator,
        stylesheet = stylesheet,
        heading = heading,
        report = report,
        ending = ending,
    )
    self.stream.write(output.encode('utf8'))


def _generate_stylesheet(self):
    return self.STYLESHEET_TMPL


def _generate_heading(self, report_attrs):
    a_lines = []
    for name, value in report_attrs:
        line = self.HEADING_ATTRIBUTE_TMPL % dict(
                name = saxutils.escape(name),
                value = saxutils.escape(value),
            )
        a_lines.append(line)
    heading = self.HEADING_TMPL % dict(
        title = saxutils.escape(self.title),
        parameters = ''.join(a_lines),
        description = saxutils.escape(self.description),
    )
    return heading


def _generate_report(self, result):
    rows = []
    sortedResult = self.sortResult(result.result)
    for cid, (cls, cls_results) in enumerate(sortedResult):
        # subtotal for a class
        np = nf = ne = 0
        for n,t,o,e in cls_results:
            if n == 0: np += 1
            elif n == 1: nf += 1
            else: ne += 1

        # format class description
        if cls.__module__ == "__main__":
            name = cls.__name__
        else:
            name = "%s.%s" % (cls.__module__, cls.__name__)
        doc = cls.__doc__ and cls.__doc__.split("\n")[0] or ""
        desc = doc and '%s: %s' % (name, doc) or name

        row = self.REPORT_CLASS_TMPL % dict(
            style = ne > 0 and 'errorClass' or nf > 0 and 'failClass' or 'passClass',
            desc = desc,
            count = np+nf+ne,
            Pass = np,
            fail = nf,
            error = ne,
            cid = 'c%s' % (cid+1),
        )
        rows.append(row)

        for tid, (n,t,o,e) in enumerate(cls_results):
            self._generate_report_test(rows, cid, tid, n, t, o, e)

    report = self.REPORT_TMPL % dict(
        test_list = ''.join(rows),
        count = str(result.success_count+result.failure_count+result.error_count),
        Pass = str(result.success_count),
        fail = str(result.failure_count),
        error = str(result.error_count),
    )
    return report


def _generate_report_test(self, rows, cid, tid, n, t, o, e):
    # e.g. 'pt1.1', 'ft1.1', etc
    has_output = bool(o or e)
    tid = (n == 0 and 'p' or 'f') + 't%s.%s' % (cid+1,tid+1)
    name = t.id().split('.')[-1]
    doc = t.shortDescription() or ""
    desc = doc and ('%s: %s' % (name, doc)) or name
    tmpl = has_output and self.REPORT_TEST_WITH_OUTPUT_TMPL or self.REPORT_TEST_NO_OUTPUT_TMPL

    # o and e should be byte string because they are collected from stdout and stderr?
    if isinstance(o,str):
        uo = e
        # TODO: some problem with 'string_escape': it escape \n and mess up formating
        # uo = unicode(o.encode('string_escape'))
        # 2.7版本uo = o.decode('latin-1')
    else:
        uo = o
    if isinstance(e,str):
        ue = e
        # TODO: some problem with 'string_escape': it escape \n and mess up formating
        # ue = unicode(e.encode('string_escape'))
        # 2.7 版本 ue = e.decode('latin-1')

    else:
        ue = e

    script = self.REPORT_TEST_OUTPUT_TMPL % dict(
        id = tid,
        output = saxutils.escape(uo+ue),
    )

    row = tmpl % dict(
        tid = tid,
        Class = (n == 0 and 'hiddenRow' or 'none'),
        style = n == 2 and 'errorCase' or (n == 1 and 'failCase' or 'none'),
        desc = desc,
        script = script,
        status = self.STATUS[n],
    )
    rows.append(row)
    if not has_output:
        return

def _generate_ending(self):
    return self.ENDING_TMPL

##############################################################################

Facilities for running tests from the command line

##############################################################################

Note: Reuse unittest.TestProgram to launch test. In the future we may

build our own launcher to support more specific command line

parameters like test title, CSS, etc.

class TestProgram(unittest.TestProgram):
“”"
A variation of the unittest.TestProgram. Please refer to the base
class for command line parameters.
“”"
def runTests(self):
# Pick HTMLTestRunner as the default test runner.
# base class’s testRunner parameter is not useful because it means
# we have to instantiate HTMLTestRunner before we know self.verbosity.
if self.testRunner is None:
self.testRunner = HTMLTestRunner(verbosity=self.verbosity)
unittest.TestProgram.runTests(self)

main = TestProgram

##############################################################################

Executing this module from the command line

##############################################################################

if name == “main”:
main(module=None)
复制代码
至于两者文件具体有什么差异,有兴趣的童鞋可以自行搜索,本文不再展开细说。

3.如何使用HTMLTestRunner?

首先先确定可以使用HTMLTestRunner:

没报错?那继续,打开Pycharm,把下面这块代码复制粘贴进去:

复制代码
import unittest
import HTMLTestRunner
class testadd(unittest.TestCase):
def setUp(self):
pass
def test_add1(self):
self.assertEqual(2 + 3 + 10,15)
def test_add2(self):
self.assertEqual(10 + 150,160)
def test_add3(self):
#一处出错,查看测试结果
self.assertEqual(2 * 5 * 7, 40)
def tearDown(self):
pass
def suite():
suiteTest=unittest.TestSuite()
suiteTest.addTest(testadd(“test_add1”))
suiteTest.addTest(testadd(“test_add2”))
suiteTest.addTest(testadd(“test_add3”))
return suiteTest
if name==“main”:

存放路径在E盘目录下

filepath=‘E:\pyresult.html’
fp=open(filepath,‘wb’)
#定义测试报告的标题与描述
runner = HTMLTestRunner.HTMLTestRunner(stream=fp,title=u’我是风起怨江南的测试报告标题’,description=u’我是风起怨江南的测试报告描述’)
runner.run(suite())
fp.close()
复制代码
运行,查看结果:

G:\helloWorld\python\pycharm\JackMeng\Scripts\python.exe G:/helloWorld/python/pycharm/JackMeng/HTMLTestRunner_demo.py
<_io.TextIOWrapper name=‘’ mode=‘w’ encoding=‘UTF-8’>
Time Elapsed=0:00:00.000948
…F

那么E盘下到底有没有生成HTML测试报告文件呢?

答案自然是生成了:

点开看看测试报告:

测试结果自然不言而喻:完美!

以上便是《Python3.x安装HTMLTestRunner和使用》的所有内容,关于《风起怨江南》在博客园在里,我更多会写一下程序安装啊、排错啊、甚至一些小程序等等,未来一定会有更多精彩的博文,所以赶紧点赞关注收藏一波吧!

当然,如果想获得更多免费的学习资料请加我的个人微信公众号——风起怨江南,最后还是感谢大家关注和支持!

转自:https://www.cnblogs.com/mengjinxiang/p/12657371.html文章来源地址https://www.toymoban.com/news/detail-406864.html

到了这里,关于python3.x安装HTMLTestRunner和使用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Linux系统安装Python3环境(超详细)_linux 安装python3

    本文基于如下Linux系统版本: 1、默认情况下,Linux会自带安装Python,可以运行python --version命令查看 如图: 我们看到Linux中已经自带了Python2.7.5。再次运行python命令后就可以使用python命令窗口了(Ctrl+D退出python命令窗口)。 2、查看Linux默认安装的Python位置 看到/usr/bin/python和

    2024年01月24日
    浏览(53)
  • python自动登录某乎、某宝、某东等网站(自学,可能不全面,笔者亲测成功,仅供参考)

    需要工具: anaconda集成环境/python、pycharm、playwright第三方库。 难点: 大型网站具有优秀的反爬机制,传统验证码以及滑块验证码是阻碍目标的最大敌手。 总思路: 大型网站都有免登录措施(登录过后,短时间内第二次登录免登录)。 依靠的是登录后服务器与浏览器共同保

    2024年02月09日
    浏览(44)
  • ubuntu 虚拟环境安装,创建python3.5和python3.8虚拟环境

    新的ubuntu20.0.4笔记本上自带点python是python3.8版本的,由于开发需要用到python3.5,一开始想把默认环境配置成python3.5算了。结果改了默认配置版本之后,坏了坏了,开机就报错,直接就进不了桌面界面了。所以,ubtuntu环境,要不是非常非常确定可以改版本,那就 千万不要改系

    2024年01月19日
    浏览(61)
  • Linux 安装Python3

    python3 下载地址 https://www.python.org/downloads/ 选择自己需要的版本、 此文中选择3.10.9 下载源码压缩包 可下载到本地后上传至Linux服务器也可以复制下载地址 yum 安装依赖包 解压python3源码压缩包 开始安装 进入解压后的目录 此时python3已安装完成、 位置在/usr/local/bin 大多数Linux系

    2024年02月04日
    浏览(37)
  • Mac安装python3

    1. 下载Python 3的安装程序:在官网https://www.python.org/downloads/上下载Python 3的安装程序。 2. 打开安装程序并运行:双击下载的安装程序并按照提示完成安装。 3. 验证Python 3的安装:在终端中输入python3并按下回车键。如果安装成功,将会看到Python 3的版本号。 4. 配置环境变量:为

    2024年02月08日
    浏览(42)
  • python3.9下载和安装教程,python3.9下载pygame2.4.0

    大家好,小编来为大家解答以下问题,python3.9下载哪个版本的tensorflow,python3.9下载哪个版本pytorch,今天让我们一起来看看吧! 目录 一、Python 下载 二、Python 安装 三、Python 配置 四、Python 验证 官网下载地址:Python Releases for Windows | Python.org (1)找到已经下载好的 exe 安装包

    2024年04月25日
    浏览(46)
  • Linux上安装python3

    记录如何在linux上安装python3及升级pip。 如果当前登录的是普通用户,需要在命令前加sudo,否则不用,下文同理。 (以python3.7.2为例)2种方法,如果linux上可使用wget命令,可以通过下面命令直接linux下载 如果linux没有安装wget命令,可以在本地下载后上传到linux上,下载地址就

    2024年02月12日
    浏览(43)
  • Python3.9.0安装教程

    一、下载安装步骤 1.官网下载地址:https://www.python.org/downloads/ 下载Python3.9.0安装包 (最新的是3.10.6,这里下载的3.9.0版本,滑到下面下载特定版本) ps:本机系统:Windows 10 (64位),去我的电脑查看,如图 2.选择电脑对应的版本下载 3.下载完成,开始安装 在安装界面你有两个

    2024年02月17日
    浏览(47)
  • ubuntu 安装 python3.9

    之前在dockerfile里面一直使用的是python3.8(忘记为什么选择这个版本了),想用python3.9,因为觉得3.8有点老了,而且3.9一个重要的feature,是把list作为默认的类型,不需要从typing 里面 import List作为数据类型了。 现在基于python3.8的dockerfile里面Python安装命令如下 但是如果直接把

    2024年02月12日
    浏览(35)
  • Ubuntu 安装Python3.8

    一、安装环境 Ubuntu2004 Python2.7 目标是将python版本从 2.7 更新到3.8 二、安装步骤 2.1 下载python3.8安装包 2.2 安装 依次执行如下步骤: 2.3 环境切换 查看目前python环境: 将python环境切换成刚刚安装的3.8 至此安装成功! 如果出现以下错误: zipimport.ZipImportError: can\\\'t decompress data; z

    2024年01月19日
    浏览(36)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包