Under my Django project there are a few apps and all of them have unit tests. One of them that I'm working right now is supposed to be included only in dev/stage environments, so I'm enabling it using a environment variable.

When this variable is present it is added to INSTALLED\_APPS and it is working just fine, the problem is that Django is executing the tests for this app even when it is not in INSTALLED\_APPS, and it fails with the following message:

> 
> ImportError: Failed to import test module: debug.tests.unit.test\_services`
> 
> 
> ...(traceback information)...
> 
> 
> RuntimeError: Model class debug.models.Email doesn't declare an explicit app\_label and isn't in an application in INSTALLED\_APPS.
> 
> 
> 

When I define the `app_label` in the `class Meta` of models in this app the error is different, it says it can't find a table, I assume that this is because the app is not in INSTALLED\_APPS, so it's migrations are not executed.

> 
> OperationalError: no such table: debug\_email
> 
> 
> 

I'm not sure why Django executes the tests for all apps, but not it's migrations.

Am I missing something from Django configuration for tests?