跟踪资源泄漏的pytest插件。

pytest-leaks的Python项目详细描述


pytest leaks-跟踪资源泄漏的pytest插件

See Package Info on PyPISee Build Status on Travis CISee Build Status on AppVeyor

跟踪资源泄漏的pytest插件。

用法

leaks:
  -R LEAKS, --leaks=LEAKS
                        runs each test several times and examines
                        sys.gettotalrefcount() to see if the test appears to
                        be leaking references. The argument should be of the
                        form stab:run where 'stab' is the number of times the
                        test is run to let gettotalrefcount settle down, 'run'
                        is the number of times further it is run. These
                        parameters all have defaults (5 and 4, respectively),
                        and the minimal invocation is '-R :'.

要将泄漏测试添加到py.test会话,请在 命令行:

$ cd examples; pytest-3 -v -R : test_faucet.py
=========================== test session starts ===========================
platform linux -- Python 3.7.4, pytest-5.0.1, py-1.8.0, pluggy-0.12.0 --
cachedir: .pytest_cache
rootdir: ..
plugins: leaks-0.3.0
collected 3 items

test_faucet.py::test_leaky_faucet LEAKED                            [ 33%]
test_faucet.py::test_broken_faucet FAILED                           [ 66%]
test_faucet.py::test_mended_faucet PASSED                           [100%]

================================ FAILURES =================================
___________________________ test_broken_faucet ____________________________

    def test_broken_faucet():
>       assert 0
E       assert 0

test_faucet.py:6: AssertionError
============================== leaks summary ==============================
examples/test_faucet.py::test_leaky_faucet: leaked references: [2, 2, 2, 2], memory blocks: [2, 2, 2, 2]
============== 1 failed, 1 passed, 1 leaked in 0.32 seconds ===============

上面使用的测试文件包含以下代码:

$ cat test_faucet.py
drops = []
def test_leaky_faucet():
    drops.append({})

def test_broken_faucet():
    assert 0

def test_mended_faucet():
    assert 1

请注意,pytest leaks多次运行测试:如果您看到测试失败 只有在使用pytest泄漏时才存在,请检查测试是否 不以阻止其运行 第二次。

功能

  • 通过反复运行py.test测试和 比较运行之间的总引用计数。

要求

  • py.test版本>;=3;
  • python的调试版本(2.7或>;=3.5)。

在linux上,python调试版本可以在包pythonX.Y-dbg中找到。 (Debian和衍生物)和python3-debug(Fedora和衍生物)。

安装

您可以通过pipPyPI

$ pip install pytest-leaks

贡献

我们非常欢迎您的贡献。测试可以使用 tox请确保覆盖范围 至少在提交请求之前保持不变。

许可证

根据MIT条款和 PSF许可证,“pytest泄漏” 是免费的开源软件。

问题

如果您遇到任何问题,请file an issue 以及详细的描述。

致谢

这个Pytest插件最初是 用Cookiecutter生成 以及@hackebrotCookiecutter-pytest-plugin 模板。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java:数组大小的插入排序问题   javahibernate抛出com。mysql。jdbc。例外情况。jdbc4。MySQLSyntaxErrorException:查看手册,了解在“localTime”时间附近使用的正确语法   java Hibernate:org。冬眠UnUniqueObjectException:具有相同标识符值的不同对象已与会话关联   Gson无法用java解析我的json日期   JavaMaven使用JDK7为JVM5编译   java(播放2.1.3)@选择返回(字符串,字符串)对   java将画布拉伸到JFrame大小   来自JTextPane的java计算输入   java如何在使用Jenkins构建不稳定的情况下回滚Tomcat?   java是否可以获取包含类(CDI)的引用?   java“IllegalArgumentException:UNMAPPABLE[1]”,同时压缩带有希腊字符的文件   使用jtwitter和SignpostClient的java永久twitter oauth   java我需要对invokeAll调用的结果进行同步吗?   java Hibernate与jointable的关系   java Selenium断言搜索结果总计与正文中的实际结果   Java接口中的JLS8类只能位于最上面的类中   如果保证在收集时调用finalize(),java年轻一代仍然可以获得速度优势?   java集成OAuth帐户和本地帐户   java如何使用Jackson在对象中包含原始JSON?