django-nose
django-nose copied to clipboard
issue with using get_app and get_apps
Hi Jeff,
I have another issue from the latest changes to django_nose/plugin.py. I will keep looking for a fix, but as a first step I am creating the ticket.
The bug is that the admin.py modules are imported twice raising the AlreadyRegistered exception.
The problem occurs because https://github.com/jbalogh/django-nose/blob/master/django_nose/plugin.py#L100 calls load_app with 'lernanta.apps.links' and https://github.com/jbalogh/django-nose/blob/master/django_nose/plugin.py#L104 causes a call to load_app with 'links'.
I will reply as soon as i find a fix (either on django_nose or on our source code). It should work if I manage to change something so that both times load_app is called with the same qualified name.
Thanks, Zuzel
@zuzelvp does killing get_apps solve the problem?
It does not solve the problem because it gets called later inside django (e.g. http://www.pastie.org/2354206).
Can you confirm the precise values that get called, is it "lernanta.apps.links" and "links"? And can I assume theres an extra models.py defined thats getting picked up with the add apps?
get_app is called directly with all the app names at: http://pastie.org/2355803 which get added to add_apps at https://github.com/jbalogh/django-nose/blob/master/django_nose/plugin.py#L82 . This are all the non-third party django apps on our django project (https://github.com/p2pu/lernanta/tree/master/apps). I presume the problem is somehow related to the directory structure of our project in which we have
project/ project/urls.py project/settings.py ... project/apps/app1/models.py project/apps/app1/tests.py ... project/apps/app2/models.py project/apps/app2/tests.py ...
get_apps produces internal calls to get_app with all the app names at: http://pastie.org/2355811
This is a log of the calls to beforeImport and the values of app_adds: http://pastie.org/2355965
I don't know how to change the implementation of plugin.py so that it can transform the qualified names discovered by nose to those in settings.py (if that is even possible). I decided to modify our project's setting.py so INSTALLED_APPS has the same qualified names as the ones discovered by nose (i.e. the complete name 'lernanta.apps.links' for all our apps). This puts a restriction to those using django_nose and customizing the admin site (or doing something that depends on not having duplicated apps on INSTALLED_APPS) but now our tests are running ok.
@zuzelvp project.apps.app1 is something like 'richtext'?
Are you modifying PYTHONPATH so that it detects all of the inner directories?
Yes, we are using site.addsitedir -- https://github.com/p2pu/lernanta/blob/master/lernanta/manage.py#L10
Is this still an issue? I'm guessing the change is to make nose aware of the changes added by site.addsitedir.