简体   繁体   中英

Unrecognized arguments YAML error when running pytest

I have a github action which runs some unit tests when a push is made to the repository. All the commands in the YAML execute successfully such as installing requirments.txt but then returns the following error when it tries to run the pytest command

python3 -m pytest verify/test.py --ds myapp.settings_pytest.

ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...] __main__.py: error: unrecognized arguments: --ds myapp.settings_pytest.

Strangely the command runs fine locally so I am confused as to why I only encounter this when it is ran from my YAML file. I am also encountering the same error when the same YAML file runs on my AWS build server.

test.yml

name: Run tests

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

env:
  django_secret_key: ${{ secrets.DJANGO_SECRET_KEY }}

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version: [3.8]

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install Dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
    - name: Run Tests
      run: |
        export DJANGO_SETTINGS_MODULE="myapp.settings_pytest"
        python3 -m pytest verify/test.py --ds myapp.settings_pytest

It has nothing to do with YML - you have to install Diango to get access to --ds options.

pip install Django==4.0.2

Or better - keep it in your requirements.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM