gpt4 book ai didi

python - python中的编译指示

转载 作者:IT老高 更新时间:2023-10-28 21:41:31 25 4
gpt4 key购买 nike

我正在阅读 bottle.py 源代码。它是一个 Web 框架,只有 3000 多行 Python 代码。太酷了。

我发现了一些这样的代码:

class ServerAdapter(object):
quiet = False
def __init__(self, host='127.0.0.1', port=8080, **config):
self.options = config
self.host = host
self.port = int(port)

def run(self, handler): # pragma: no cover
pass
...

# pragma: no cover 是什么意思?我在 python 文档中找不到任何关于 pragma 语法的介绍。

最佳答案

显然与 coverage.py 有关:

Coverage.py is a tool for measuring code coverage of Python programs. It monitors your program, noting which parts of the code have been executed, then analyzes the source to identify code that could have been executed but was not.

确切的 # pragma: no cover 提示该工具应忽略该部分代码 -- 参见 Excluding code from coverage .

关于python - python中的编译指示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11992448/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com