Opened 10 years ago

Closed 10 years ago

#24618 closed Bug (invalid)

Incorrect duplicate app message shown when no duplicates found

Reported by: Ross Crawford-d'Heureuse Owned by: nobody
Component: Testing framework Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

https://github.com/django/django/pull/4476

Details of this bug are in the ticket but over view is

I have an app with construct: project_name.apps.core

Consistently got: when running tests

django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: core

Despite absolutely no chance of it being duplicate;

print of apps form within registry.py

('project_name.apps.v2_api', 'project_name.apps.v1_api', 'project_name.apps.applications', 'project_name.apps.backend', 'project_name.apps.core', 'project_name.apps.tools', 'project_name.apps.me', 'project_name.apps.brand', 'project_name.apps.workorder', 'project_name.apps.batch', 'project_name.apps.printer', 'project_name.apps.scan', 'project_name.apps.code', 'project_name.apps.dash', 'project_name.apps.role_permission')

Considered it being a conflict with django.core (but seems not to be the case)

Am using a custom test runner

class AppTestRunner(DiscoverRunner):
    def build_suite(self, test_labels, *args, **kwargs):
        # not args passed in
        if not test_labels:
            test_labels = settings.PROJECT_APPS

        return super(AppTestRunner, self).build_suite(test_labels, *args, **kwargs)

As you can see the runner runs test tests from ONLY the project and not the dango/helper app test cases

I noticed there has been a very recent refactor (march) of the registry; which is what prompted the investigation as I have had a 1.7 merge branch for this project for some time and the tests have always run with no issue. I recently re installed django (1, 7, 5, 'final', 0) and this error started happening.

I hope the fix makes sense.

Change History (9)

comment:1 by Tim Graham, 10 years ago

Description: modified (diff)

comment:2 by Tim Graham, 10 years ago

Can you upload a sample project or tell us how we can reproduce this? It seems like you might have an issue in your project as I don't understand why the proposed change needs to be made in Django.

comment:3 by Ross Crawford-d'Heureuse, 10 years ago

Hi Tim,

I have described and documented the issue in both the ticket and the PR.

I also thought it to be a bug within my project but after extensive investigation its actually not.

In a custom testRunner (extending the default django runner in runner.py) if I inject a tuple of JUST my projects apps the duplicate error arises.

Please review the PR at: https://github.com/django/django/pull/4476

Regards
Ross

comment:4 by Tim Graham, 10 years ago

I tried to reproduce it with the project structure you described, but wasn't having any luck. Is it only an issue with the custom test runner? I didn't try adding that.

comment:5 by Ross Crawford-d'Heureuse, 10 years ago

Hi there app setup and test runner below.

DJANGO_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

PROJECT_APPS = (
    'my_project.apps.v2_api',
    'my_project.apps.v1_api',
    'my_project.apps.applications',
    'my_project.apps.backend',
    'my_project.apps.core',
    'my_project.apps.tools',
    'my_project.apps.me',
    'my_project.apps.brand',
    'my_project.apps.workorder',
    'my_project.apps.batch',
    'my_project.apps.printer',
    'my_project.apps.scan',
    'my_project.apps.code',
    'my_project.apps.dash',
    'my_project.apps.role_permission',
)

HELPER_APPS = (
    'pipeline',
    'registration',
    'password_reset',
    'django_extensions',
    'raven.contrib.django.raven_compat',

    'parsley',
    'corsheaders',
    'crispy_forms',
    'rest_framework',
)

INSTALLED_APPS = DJANGO_APPS + PROJECT_APPS + HELPER_APPS
from django.test.runner import DiscoverRunner


class AppTestRunner(DiscoverRunner):
    def build_suite(self, test_labels, *args, **kwargs):
        # not args passed in
        if not test_labels:
            test_labels = settings.PROJECT_APPS

        return super(AppTestRunner, self).build_suite(test_labels, *args, **kwargs)
Last edited 10 years ago by Miroslav Shubernetskiy (previous) (diff)

comment:6 by Tim Graham, 10 years ago

Unfortunately, I still can't reproduce it with those details. Could you try putting together a minimal project that reproduces the error that we could download? A regression test for Django's test suite to complement your patch might be fine too.

comment:7 by Ross Crawford-d'Heureuse, 10 years ago

Ill try allocate some time for it! :) thanks

comment:8 by Ross Crawford-d'Heureuse, 10 years ago

Ok, so this is very strange. I've re-installed django 1.7 (not change to version tho) aaaand its working.

have been running clean_pyc as well as custom make clean command that looks for pyc files.

..

I guess the bug is invalid.. I apologise for wasting time. And thank you for your efforts to reproduce.

comment:9 by Tim Graham, 10 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top