Reputation: 117
Trying to print text "Logged in" in Jenkins through a test case such as:
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")
In Jenkins my Build Execute Shell Command reads:
cd path/to/test
py.test --cov
Currently the Jenkins console output does not show the print statement however it does show when I run it on my personal computer
Upvotes: 1
Views: 4667
Reputation: 17511
Can you add this at the beginning of your python script:
#!/usr/bin/env python -u
What -u
does:
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.
or:
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
Upvotes: 3