views:

72

answers:

2

I learnt that using Customizable Authencation backends philosophy, one can create a website which accepts email addresses as usernames. But after building the corresponding logic and testing that my code is working fine, I found one issue with Django's own testcases. They were failing to follow the Customizable Authencation backend philosophy. Meaning, the testcases were actually having hardcoded values('username': 'testclient') for testing the "login" process. Why is that? Django always discourages Tight Coupling. But whats happening here?

I am not bashing Django by any means! I am a big fan and I will be, for years to come. Just want to know the reason behind this!

Update: As @dmishe pointed out those testcases should validate Django's own functionality. I understood that. But how do I let those "failing testcase" errors NOT show up when I run my testcases or run the whole project test suite?

A: 

I don't see a problem here, django.contrib.auth.tests should test auth app and nothing more. Thus, it should test built-in backend which is username/password combination.

Dmitry Shevchenko
@dmishe! You are right. The more I think about it, the more I am inclined towards finding that, its actually true. But I couldn't be expecting Django's testcases to fail, when I am running my testcases. So is there a feasible solution/workaround just to bypass this problem?
Maddy
+1  A: 

As dmishe points out, it is not a problem that the contrib.auth tests test the functionality that is built in to the contrib.auth app. It is a problem that those tests are run for user projects by default, and it is easy to break them via normal settings customization. This is a problem the Django developers are aware of and working on possible solutions.

In the meantime, my solution is to define a simple bash script to test only the apps I want to. So instead of "./manage.py test" I run a script that does "./manage.py test app1 app2 app3...". Not perfect, but it's far from the worst of my problems :-)

Update: This commit might interest you.

Carl Meyer
I expected to solve this with unittest suites. But still, it needs app1, app2, app3 mentioned scenario. So for now I will go with this. But waiting a better solution....
Maddy
@Carl Thanks about the suggestion. I tried the same approach by overriding settings.INSTALLED_APPS and I removed django.contrib.auth from settings.INSTALLED_APPS(for bypassing "auth" tests). It resulted in the non-creation of "auth_user" table, which is needed for all my other tests. So no luck :(
Maddy