我正在将python项目切换到用于依赖和包装管理的诗歌,并且我遇到了让我的github动作单元测试工作的问题。我认为问题在于诗歌并没有安装我的软件包。当我在本地运行poetry install
时,在它安装依赖项之后,它显示它安装了当前项目,行:
Installing the current project: monaco (0.1.0)
然而当我运行poetry install
在github的行动,它安装的依赖关系但从未显示线安装当前项目。这里是github测试日志的上下文,查看"安装库"的一步。然后,当我尝试在此之后运行测试时,它们会失败,因为它们找不到包:
ImportError while importing test module '/home/runner/work/monaco/monaco/tests/test_MCCase.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_MCCase.py:4: in <module>
from monaco.MCCase import MCCase
E ModuleNotFoundError: No module named 'monaco'
这是我第一次用诗,所以我可能在什么地方做了什么傻事。但我花了几个小时想弄明白,却毫无头绪。任何帮助将非常感激!
我的unit_test。Yml文件看起来像这样:
name: Unit Tests
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install library
run: poetry install
- name: Run tests
run: |
poetry run python -m pytest
原来我是个白痴,我刚刚把我的项目从"Monaco"到"摩纳哥",但忘记将模块目录名更新为小写。