Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.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 pytest会话在完成所有测试后未结束_Python_Jenkins_Pytest - Fatal编程技术网

Python pytest会话在完成所有测试后未结束

Python pytest会话在完成所有测试后未结束,python,jenkins,pytest,Python,Jenkins,Pytest,我正在尝试将pytests集成到我的Jenkins项目中,但Jenkins作业无法完成,因为pytest的测试会话尚未结束 下面是我能想到的最简单的例子: Python测试: import pytest import sys, time sys.path.append('../../bindings/python') class TestControl(): def test_sanity_check(self): """ Basic Test

我正在尝试将pytests集成到我的Jenkins项目中,但Jenkins作业无法完成,因为pytest的测试会话尚未结束

下面是我能想到的最简单的例子:

Python测试:

import pytest
import sys, time
sys.path.append('../../bindings/python')

class TestControl():
    def test_sanity_check(self):
        """
        Basic Test
        """
        assert (True)
控制台命令和输出:

 python git:(ed25b33) ✗ sudo nano test_control.py 
➜  python git:(ed25b33) ✗ sudo python3 -m pytest -s test_control.py::TestControl::test_sanity_check
=============================================================================================================================== test session starts ===============================================================================================================================
platform linux -- Python 3.4.3, pytest-3.3.2, py-1.5.2, pluggy-0.6.0
rootdir: /var/lib/jenkins/workspace/examples/python, inifile:
collected 1 item                                                                                                                                                                                                                                                                  

test_control.py .                                                                                                                                                                                                                                                           [100%]

============================================================================================================================ 1 passed in 0.67 seconds =============================================================================================================================

测试显示100%已完成,但由于某些原因没有终止会话。我尝试在脚本中添加sys.exit(),但它导致了一个错误。我只需要测试来释放控制台,这样我的Jenkins工作就可以完成。

结果是我有一个setup_类,但没有teardown_类,我的类实例仍然处于活动状态,并阻止了测试会话的结束