'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



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Grzegorz Krukowski