把test_jenkins.py文件改了一下import,改为了from ..jenkins import app,可以了,但是运行nosetests的时候报这个错误:
[PythonWeb] $ /bin/sh -xe /tmp/jenkins6157304261149438688.sh
+ /usr/local/bin/nosetests --with-coverage --with-xunit --cover-package=jenkins --cover-erase
.
Coverage.py warning: Module jenkins was never imported. (module-not-imported)
Name Stmts Miss Cover
---------------------------
Traceback (most recent call last):
File "/usr/local/bin/nosetests", line 11, in <module>
sys.exit(run_exit())
File "/usr/local/lib/python3.5/dist-packages/nose/core.py", line 121, in __init__
**extra_args)
File "/usr/lib/python3.5/unittest/main.py", line 94, in __init__
self.runTests()
File "/usr/local/lib/python3.5/dist-packages/nose/core.py", line 207, in runTests
result = self.testRunner.run(self.test)
File "/usr/local/lib/python3.5/dist-packages/nose/core.py", line 66, in run
result.printErrors()
File "/usr/local/lib/python3.5/dist-packages/nose/result.py", line 110, in printErrors
self.config.plugins.report(self.stream)
File "/usr/local/lib/python3.5/dist-packages/nose/plugins/manager.py", line 99, in __call__
return self.call(*arg, **kw)
File "/usr/local/lib/python3.5/dist-packages/nose/plugins/manager.py", line 167, in simple
result = meth(*arg, **kw)
File "/usr/local/lib/python3.5/dist-packages/nose/plugins/cover.py", line 183, in report
self.coverInstance.stop()
File "/usr/local/lib/python3.5/dist-packages/coverage/control.py", line 1041, in report
return reporter.report(morfs, outfile=file)
File "/usr/local/lib/python3.5/dist-packages/coverage/summary.py", line 158, in report
raise CoverageException("No data to report.")
coverage.misc.CoverageException: No data to report.
+ exit 0
[Cobertura] Publishing Cobertura coverage report...
[Cobertura] No coverage results were found using the pattern 'coverage.xml' relative to '/var/lib/jenkins/workspace/PythonWeb'. Did you enter a pattern relative to the correct directory? Did you generate the XML report(s) for Cobertura?
ERROR: Step ‘Publish Cobertura Coverage Report’ failed: [Cobertura] No coverage results were found using the pattern 'coverage.xml' relative to '/var/lib/jenkins/workspace/PythonWeb'. Did you enter a pattern relative to the correct directory? Did you generate the XML report(s) for Cobertura?
Recording test results
Finished: FAILURE