问题描述
我正在尝试配置travis,以自动测试我的python应用。
我正在使用python3,tkinter和gi。
经过多次尝试后,我的.travis.yml如下:
language: python
python:
- "3.8"
before_install:
- python --version
- pip install -U pip
- pip install -U pytest
# command to install dependencies
install:
- sudo apt-get update
- sudo apt-get install python3
- sudo apt-get install python3-gi
- sudo apt-get install python3-tk
- sudo apt install python-pytest
- pip install -r requirements.txt
- pip3 install --upgrade pip
- pip3 install pytest
# command to run tests
script:
- python3 -m pytest tests/*
问题如下:
==================================== ERRORS ====================================
_______________ ERROR collecting tests/tests_custom_indicator.py _______________
ImportError while importing test module '/home/travis/build/JustalK/Indicators/tests/tests_custom_indicator.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../virtualenv/python3.8.0/lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:],package,level)
tests/tests_custom_indicator.py:1: in <module>
from src.init import Init
src/__init__.py:1: in <module>
from src.init import Init
src/init.py:2: in <module>
from src.indicator import Indicator
src/indicator.py:4: in <module>
import gi
E ModuleNotFoundError: No module named 'gi'
_______________ ERROR collecting tests/tests_custom_indicator.py _______________
ImportError while importing test module '/home/travis/build/JustalK/Indicators/tests/tests_custom_indicator.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../virtualenv/python3.8.0/lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:],level)
tests/tests_custom_indicator.py:1: in <module>
from src.init import Init
src/__init__.py:1: in <module>
from src.init import Init
src/init.py:2: in <module>
from src.indicator import Indicator
src/indicator.py:4: in <module>
import gi
E ModuleNotFoundError: No module named 'gi'
=========================== short test summary info ============================
ERROR tests/tests_custom_indicator.py
ERROR tests/tests_custom_indicator.py
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!
============================== 2 errors in 0.08s ===============================
The command "python3 -m pytest tests/*" exited with 2.
如您所见,即使我安装了python3-gi,travis-ci中的登录也会在unknow模块上返回错误。但是,如果我在本地尝试该命令,一切都会很好。
我过去了几个小时,现在开始失去它了:X
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)