Jenkins Python打印控制台输出

Jenkins Python打印控制台输出,python,linux,selenium,jenkins,Python,Linux,Selenium,Jenkins,试图通过测试用例打印Jenkins中登录的文本,例如: import unittest from #path.to.methods import method Class TC1(unittest.TestCase): def test_tc01(self): self.driver = webdriver.chrome() driver = method(self.driver) driver.login() print

试图通过测试用例打印Jenkins中登录的文本,例如:

import unittest
from #path.to.methods import method
Class TC1(unittest.TestCase):
    def test_tc01(self):
        self.driver = webdriver.chrome()
        driver = method(self.driver)
        driver.login()
        print ("Logged in") 
在Jenkins中,我的Build Execute Shell命令如下:

cd path/to/test
py.test --cov

目前,Jenkins控制台的输出没有显示print语句,但是当我在个人计算机上运行print语句时,它会显示出来

#!/usr/bin/env python -u
u做什么:

或:


您可能需要刷新输出。作为jenkins控制台,sys.stdout.flush可以随心所欲。您正在运行哪些操作系统?我正在Linux上运行jenkins
 python -u
-u     Force  stdin,  stdout  and stderr to be totally unbuffered.  On systems where it matters, also put
       stdin, stdout and stderr in binary mode.  Note that there is internal buffering  in  xreadlines(),
       readlines()  and  file-object  iterators ("for line in sys.stdin") which is not influenced by this
           option.  To work around this, you will want to use  "sys.stdin.readline()"  inside  a  "while  1:"
           loop.
import unittest
import sys #<--this 
from #path.to.methods import method
Class TC1(unittest.TestCase):
    def test_tc01(self):
        self.driver = webdriver.chrome()
        driver = method(self.driver)
        driver.login()
        print ("Logged in")
        sys.stdout.flush() #<--and this