Django test discovery and RuntimeError: Conflicting 'entry_tags' models in application 'entries': <class ' entries.models.Entry_tags'> and <class 'src.apps.entries.models.Entry_tags'>.

629 views
Skip to first unread message

Petey

unread,
Nov 1, 2014, 2:14:17 PM11/1/14
to django...@googlegroups.com
Hello!

I've written on that topic here:
http://stackoverflow.com/questions/26688775/django-cant-discover-tests-correctly

What I discovered is:
- unittest.loader ignores directories which are provided manually in settings to sys.path
- unittest.loader requires __init__.py in a directory to look there for tests

When __init__.py is in apps directory then I am getting a:
RuntimeError: Conflicting 'entry_tags' models in application 'entries': <class '
entries.models.Entry_tags'> and <class 'src.apps.entries.models.Entry_tags'>.

How do I resolve this?

Petey

unread,
Nov 1, 2014, 2:50:02 PM11/1/14
to django...@googlegroups.com
I did a simple workaround for this.

http://stackoverflow.com/a/26691861/926961

but in my opinion it should get fixed somehow without workarounds :)

Collin Anderson

unread,
Nov 2, 2014, 8:42:54 PM11/2/14
to django...@googlegroups.com
Hello,

The problem is that both D:\projekty\ogloszenia and D:\projekty\ogloszenia\src\apps are on your python path.

The recommended way to do it is to import all of your code relative to manage.py and only have that directory on your python path, so in your case, that would be:
src.apps.entries.models.Entry_tags
src.project.settings

Or, in your case it may make sense to put the manage.py in your src folder, making it:
apps.entries.models.Entry_tags
project.settings

If you don't want the "apps" prefix on your apps, you may want to consider moving them up one level and removing the apps directory.

Collin

Reply all
Reply to author
Forward
0 new messages