Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在py.test运行期间调试内存使用情况_Python_Unit Testing_Memory Leaks_Pytest - Fatal编程技术网

Python 在py.test运行期间调试内存使用情况

Python 在py.test运行期间调试内存使用情况,python,unit-testing,memory-leaks,pytest,Python,Unit Testing,Memory Leaks,Pytest,我们有一个单独运行时通过的测试。但是如果我们运行所有测试,py.test会失败,因为没有内存 我的问题:如何在每次测试前后显示py.test进程的内存使用情况 这样我们就可以找到内存泄漏的测试 其他解决方案也是受欢迎的 我们在linux上运行Python 2.7 内存问题的根源已经解决:Django更改了Queryset迭代以加载所有实例。就我而言,数百万人:-)见: 但我仍然对一般问题感兴趣。pytest xdist插件为您提供了--装箱选项,其中每个测试都在自己的子进程中运行 您可以使用它来

我们有一个单独运行时通过的测试。但是如果我们运行所有测试,
py.test
会失败,因为没有内存

我的问题:如何在每次测试前后显示py.test进程的内存使用情况

这样我们就可以找到内存泄漏的测试

其他解决方案也是受欢迎的

我们在linux上运行Python 2.7

内存问题的根源已经解决:Django更改了Queryset迭代以加载所有实例。就我而言,数百万人:-)见:


但我仍然对一般问题感兴趣。

pytest xdist插件为您提供了
--装箱
选项,其中每个测试都在自己的子进程中运行

您可以使用它来处理测试,还可以跟踪资源使用情况(不确定如何使用atm)

最后,很有可能是测试的交互作用,而不是单个测试堆积了记忆。您可以使用
-k
选择器或
pytest random
插件的标志
--random
来验证我的猜测


这是一个python项目还是您只是在用python编写测试?另外,你确定这是因为内存使用吗?@khajvah这是一个用Python编写的项目。