Прелюдия для существования этой проблемы состоит в том, что я пытаюсь выяснить, как лучший способ импортировать модули из параллельных папок. Текущая сборка выглядит так: < /p>
Repository
| Encompassing_Folder
|| src
||- __init__.py
||- alice.py
|
|| tests
||- test_a.py
|
|- __init__.py
Я использую прямой импорт, поэтому при запуске test_a.py вручную я указываю путь с Python -m Ecnompassing_folder.tests.test_a , который позволяет застройщику найти родительскую папку и его полное содержание. Ниже я даю свой файл рабочего процесса, если он имеет какое -либо использование.name: Python application
on:
push:
branches: [ "main", "release/*" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
PYTHONPATH: ./Encompassing_Folder:./Encompassing_Folder/src
run: |
pytest
Подробнее здесь: https://stackoverflow.com/questions/794 ... ub-actions
Регулировка $ pythonpath для Pytest в GitHub Actions ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Почему я получаю нулевые значения для переменных GitHub Actions в тестах Python pytest?
Anonymous » » в форуме Python - 0 Ответы
- 8 Просмотры
-
Последнее сообщение Anonymous
-