How to run unit tests on a modified Open edX Devstack without pytest_load_initial_conftests or settings.DATABASES errors?

While trying to execute unit tests inside the LMS shell using pytest, I’m facing configuration issues in a customized Open edX Devstack setup.

The traceback shows errors related to pytest_load_initial_conftests and Django settings misconfiguration, particularly with settings.DATABASES.

It seems like pytest-django is unable to detect the right settings module. I’m unsure which Django settings file or environment variable (DJANGO_SETTINGS_MODULE) needs modification to make tests run correctly in this custom environment.

Has anyone faced this issue while running tests in a modified Open edX setup?

How can I properly configure pytest to recognize the right settings module?