0

I've deployed a Django app and would like to get Heroku CI setup. I have a suite of tests that run locally. On heroku CI test setup succeeds and then the test runner fails with the following error log (abbreviated):

==================================== ERRORS ====================================

________________________ ERROR collecting test session _________________________

.heroku/python/lib/python3.8/site-packages/_pytest/config/__init__.py:495: in _importconftest

    return self._conftestpath2mod[key]

E   KeyError: PosixPath('/app/.heroku/python/lib/python3.8/site-packages/django_dynamic_fixture/tests/conftest.py')

During handling of the above exception, another exception occurred:

...

.heroku/python/lib/python3.8/site-packages/django/db/models/base.py:112: in __new__

    raise RuntimeError(

E   RuntimeError: Model class django_dynamic_fixture.models_sample_app.Publisher doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

As you can see, this error originates in an imported module (django_dynamic_fixture) which runs fine locally. I think this may be due to how heroku ci is configured and therefore I don't know what I can do to solve this issue.

The doesn't declare an explicit app_label... error is probably due to mixing absolute and relative imports, or from a missing django.contrib.sites app in the django settings file. However because the tests run locally, I'm unsure how to proceed.

John
  • 949
  • 1
  • 9
  • 20
  • Have you checked your `settings_dev.py` & `settings_prod.py` (supposing you have them separately) both have the app name in `INSTALLED APPS` list? – Laenka-Oss Jul 17 '20 at 13:52
  • settings files and INSTALLED_APPS are ok - i can run tests locally specifying the settings.test file. It appears to be something on the heroku platform itself – John Jul 17 '20 at 19:24

1 Answers1

0

The problem was caused by using the ignore option. Instead of using ignore, use norecursedirs instead.

Also, tests are run from the app/ dir, so any norecursedirs should not include this dir, but only its children. e.g. .heroku, not app/.heroku

John
  • 949
  • 1
  • 9
  • 20