Jenkins向我发送错误:ImportError:不支持按文件名导入

2024-09-27 21:33:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我的问题是:我正在尝试将jenkins与我的python项目集成,在那里我已经能够配置pep8和pylint之类的东西,但是我现在正在尝试通过unittest进行测试。这就是我在配置中所做的:

python-m unittestdtzerp/apps/rh/controlasistencia>;构建/pytest/单元测试.xml

用黑体字写的就是我的测试.py文件的位置,它实现了测试,斜体字是我应该保存带有测试结果的.xml文件的位置,但是在构建构建时,它会生成这个错误,而且当我转到.xml文件时,它会告诉我它是空的。你知道吗

Started by user Admin
Building in workspace /opt/jenkins-2.46.2-0/apps/jenkins/jenkins_home   /workspace/VERSAT_ERP > /opt/jenkins-2.46.2-0/git/bin/git rev-parse --is-   inside-work-tree # timeout=10 Fetching changes from the remote Git repository
> /opt/jenkins-2.46.2-0/git/bin/git config remote.origin.url    http://admin@gitlab.datazucar.cu/python/Versat-ERP.git # timeout=10
Fetching upstream changes from http://admin@gitlab.datazucar.cu   /python/Versat-ERP.git > /opt/jenkins-2.46.2-0/git/bin/git --version #     timeout=10 using GIT_ASKPASS to set credentials > /opt/jenkins-2.46.2-0   /git/bin/git fetch --tags --progress        http://mario.garcia@gitlab.datazucar.cu/python/Versat-ERP.git +refs/heads   /*:refs/remotes/origin/*
> /opt/jenkins-2.46.2-0/git/bin/git rev-parse refs/remotes/origin   /develop^{commit} # timeout=10
> /opt/jenkins-2.46.2-0/git/bin/git rev-parse refs/remotes/origin /origin  /develop^{commit} # timeout=10
Checking out Revision de3830e8dd4a7afb471e2f10a81af2552991a4e0      (refs/remotes/origin/develop)
Commit message: "Mario --- Subiendo archivo test.py para probar   integracion con el jenkins"
> /opt/jenkins-2.46.2-0/git/bin/git config core.sparsecheckout #     timeout=10
> /opt/jenkins-2.46.2-0/git/bin/git checkout -f   de3830e8dd4a7afb471e2f10a81af2552991a4e0
> /opt/jenkins-2.46.2-0/git/bin/git rev-list    de3830e8dd4a7afb471e2f10a81af2552991a4e0 # timeout=10
Run condition [Execute Shell] enabling prebuild for step [Invoke Ant]
Run condition [Execute Shell] enabling prebuild for step [Invoke Ant]
Run condition [Execute Shell] enabling prebuild for step [Invoke Ant]
Run condition [Execute Shell] enabling prebuild for step [Invoke Ant]
[VERSAT_ERP] $ /bin/sh -xe /opt/jenkins-2.46.2-0/apache-tomcat    /temp/CommandInterpreterCondition2731773612737679824.sh
+ pep8 --max-line-length=120 dtzerp/apps/admin/
Run condition [Execute Shell] preventing perform for step [Invoke Ant]
[VERSAT_ERP] $ /bin/sh -xe /opt/jenkins-2.46.2-0/apache-tomcat   /temp/CommandInterpreterCondition22160854813579713.sh
+ pylint --output-format=parseable --reports=y dtzerp/apps/admin/      --disable=w0611,w0614,f0401,cd301 --max-line-length=120    --rcfile=build/pylint  /pylint.cfg
No config file found, using default configuration
Run condition [Execute Shell] preventing perform for step [Invoke Ant]
[VERSAT_ERP] $ /bin/sh -xe /opt/jenkins-2.46.2-0/apache-tomcat    /temp/CommandInterpreterCondition3358860767606403541.sh
+ sloccount --duplicates --wide --details dtzerp/apps/admin/
Run condition [Execute Shell] enabling perform for step [Invoke Ant]
[VERSAT_ERP] $ /opt/jenkins-2.46.2-0/apps/jenkins/jenkins_home/tools   /hudson.tasks.Ant_AntInstallation/Ant_1.10.1/bin/ant
Buildfile: /opt/jenkins-2.46.2-0/apps/jenkins/jenkins_home/workspace     /VERSAT_ERP/build.xml

init:

BUILD SUCCESSFUL
Total time: 0 seconds
[VERSAT_ERP] $ /bin/sh -xe /opt/jenkins-2.46.2-0/apache-tomcat  /temp/CommandInterpreterCondition5200661985837307314.sh
+ python -m unittest dtzerp/apps/rh/controlasistencia
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/unittest/__main__.py", line 12, in <module>
main(module=None)
File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs
self.createTests()
File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests
self.module)
File "/usr/lib/python2.7/unittest/loader.py", line 130, in     loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python2.7/unittest/loader.py", line 91, in   loadTestsFromName
module = __import__('.'.join(parts_copy))
ImportError: Import by filename is not supported.

Run condition [Execute Shell] preventing perform for step [Invoke Ant]
[WARNINGS] Parsing warnings in files 'build/pep8/pep8.xml' with parser   Pep8
[WARNINGS] Searching for all files in /opt/jenkins-2.46.2-0/apps/jenkins /jenkins_home/workspace/VERSAT_ERP that match the pattern build/pep8/pep8.xml
[WARNINGS] Parsing 1 file in /opt/jenkins-2.46.2-0/apps/jenkins  /jenkins_home/workspace/VERSAT_ERP
[WARNINGS] Successfully parsed file /opt/jenkins-2.46.2-0/apps/jenkins  /jenkins_home/workspace/VERSAT_ERP/build/pep8/pep8.xml with 940 unique     warnings and 0 duplicates.
[WARNINGS] Parsing warnings in files 'build/pylint/pylint.xml' with   parser PyLint
[WARNINGS] Searching for all files in /opt/jenkins-2.46.2-0/apps/jenkins /jenkins_home/workspace/VERSAT_ERP that match the pattern build/pylint  /pylint.xml
[WARNINGS] Parsing 1 file in /opt/jenkins-2.46.2-0/apps/jenkins /jenkins_home/workspace/VERSAT_ERP
[WARNINGS] Successfully parsed file /opt/jenkins-2.46.2-0/apps/jenkins /jenkins_home/workspace/VERSAT_ERP/build/pylint/pylint.xml with 2933   unique   warnings and 0 duplicates.
[WARNINGS] Parsing warnings in console log with parser Pep8
[WARNINGS] Parsing warnings in console log with parser PyLint
[WARNINGS] Computing warning deltas based on reference build #88
Recording test results
Build step 'Publish JUnit test result report' changed build result  to   UNSTABLE
[SLOCCount] Report successfully processed and all data stored
Finished: UNSTABLE

Tags: appsinpygitforerpbinline

热门问题