Bug with testing framework when not using contrib.auth

32 views
Skip to first unread message

Yo-Yo Ma

unread,
Nov 2, 2010, 2:43:02 PM11/2/10
to Django developers
I have a large application that doesn't user contrib.auth, and when I
run `manage.py test` I get a slough of 35 errors, all of which are
DatabaseError: no such table: auth_user (differing Tracebacks for
each). I don't have any actual tests yet, just the SimpleTest that
comes free in tests.py. INSTALLED_APPS is:

'django.contrib.sessions',
'django.contrib.messages',
'myproject.myapp', # Plus 8 more custom apps omitted.


With this bug, Django's testing framework is seemingly coupled to a
contrib app.

One of the Tracebacks:

======================================================================
ERROR: test_add
(django.contrib.messages.tests.user_messages.UserMessagesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python26\Lib\site-packages\django-trunk\django\contrib
\messages\tests\user_messages.py", line 13, in setUp
self.user = User.objects.create(username='tester')
File "C:\Python26\Lib\site-packages\django-trunk\django\db\models
\manager.py", line 138, in create
return self.get_query_set().create(**kwargs)
File "C:\Python26\Lib\site-packages\django-trunk\django\db\models
\query.py", line 351, in create
obj.save(force_insert=True, using=self.db)
File "C:\Python26\Lib\site-packages\django-trunk\django\db\models
\base.py", line 452, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
File "C:\Python26\Lib\site-packages\django-trunk\django\db\models
\base.py", line 545, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
File "C:\Python26\Lib\site-packages\django-trunk\django\db\models
\manager.py", line 195, in _insert
return insert_query(self.model, values, **kwargs)
File "C:\Python26\Lib\site-packages\django-trunk\django\db\models
\query.py", line 1490, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Python26\Lib\site-packages\django-trunk\django\db\models\sql
\compiler.py", line 786, in execute_sql
cursor = super(SQLInsertCompiler, self).execute_sql(None)
File "C:\Python26\Lib\site-packages\django-trunk\django\db\models\sql
\compiler.py", line 730, in execute_sql
cursor.execute(sql, params)
File "C:\Python26\Lib\site-packages\django-trunk\django\db\backends
\sqlite3\base.py", line 221, in execute
return Database.Cursor.execute(self, query, params)
DatabaseError: no such table: auth_user

David P. Novakovic

unread,
Nov 2, 2010, 8:18:48 PM11/2/10
to django-d...@googlegroups.com
This is certainly an artifact of the fact that messages recent started
supporting anonymous messages. Previously it depended on auth.

I suspect you just need to open a ticket for this.

> --
> You received this message because you are subscribed to the Google Groups "Django developers" group.
> To post to this group, send email to django-d...@googlegroups.com.
> To unsubscribe from this group, send email to django-develop...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
>
>

Russell Keith-Magee

unread,
Nov 2, 2010, 8:26:56 PM11/2/10
to django-d...@googlegroups.com
On Wed, Nov 3, 2010 at 8:18 AM, David P. Novakovic
<davidno...@gmail.com> wrote:
> This is certainly an artifact of the fact that messages recent started
> supporting anonymous messages. Previously it depended on auth.
>
> I suspect you just need to open a ticket for this.

Yes - this is oversight, not intention.

contrib.messages depends on contrib.auth for reasons of backwards
compatibility, but unless you're using the legacy fallback storage
mechanism, that dependency doesn't exist in practice. You're the first
person to report this dependency as a practical concern.

I suspect we'll need to crack out some of the new unittest2 features
to fix this; skipping the user_messages tests unless contrib.auth is
available.

Yours,
Russ Magee %-)

Yo-Yo Ma

unread,
Nov 3, 2010, 1:43:29 AM11/3/10
to Django developers
I've been using CookieStorage (for less DB usage). Us that frowned
upon nowadays, in favor of the DB backend?

On Nov 2, 6:26 pm, Russell Keith-Magee <russ...@keith-magee.com>
wrote:
> On Wed, Nov 3, 2010 at 8:18 AM, David P. Novakovic
>
> >> For more options, visit this group athttp://groups.google.com/group/django-developers?hl=en.

Yo-Yo Ma

unread,
Nov 3, 2010, 1:54:53 AM11/3/10
to Django developers
BTW, my program doesn't have any issues with gangrene. I meant "a slew
of 35 errors" in my original post. Sometimes I look back at what I've
typed and it amazes me.

On Nov 2, 6:26 pm, Russell Keith-Magee <russ...@keith-magee.com>
wrote:
> On Wed, Nov 3, 2010 at 8:18 AM, David P. Novakovic
>
> >> For more options, visit this group athttp://groups.google.com/group/django-developers?hl=en.

Russell Keith-Magee

unread,
Nov 3, 2010, 8:11:44 AM11/3/10
to django-d...@googlegroups.com
On Wed, Nov 3, 2010 at 1:43 PM, Yo-Yo Ma <baxters...@gmail.com> wrote:
> I've been using CookieStorage (for less DB usage). Us that frowned
> upon nowadays, in favor of the DB backend?

There is no "db" backend for messages, there is only a "legacy"
backend, which, as the name suggests, is for legacy applications --
applications that used Django's older (pre 1.2) user-messages table
and need to migrate to using the Django-1.2 messages framework.

There is a db backend for sessions, but the choice of session backend
is independent of the choice of messages backend.

The "right" solution is entirely up to your own requirements; Django
doesn't discourage the use of any of the options it provides, other
than to say that the legacy backend only exists for backwards
compatibility purposes.

Yours,
Russ Magee %-)

Yo-Yo Ma

unread,
Nov 3, 2010, 3:58:04 PM11/3/10
to Django developers
Ok, thanks. I'm using CookieStorage for messages, so the issue may not
reside only with legacy storage. Should I create a ticket for this?


On Nov 3, 6:11 am, Russell Keith-Magee <russ...@keith-magee.com>
wrote:

Russell Keith-Magee

unread,
Nov 3, 2010, 7:26:30 PM11/3/10
to django-d...@googlegroups.com
On Thu, Nov 4, 2010 at 3:58 AM, Yo-Yo Ma <baxters...@gmail.com> wrote:
> Ok, thanks. I'm using CookieStorage for messages, so the issue may not
> reside only with legacy storage. Should I create a ticket for this?

If you'd be so kind.

Yours,
Russ Magee %-)

Yo-Yo Ma

unread,
Nov 6, 2010, 3:42:28 PM11/6/10
to Django developers
Ok, I finally created a ticket for this: http://code.djangoproject.com/ticket/14632

On Nov 3, 5:26 pm, Russell Keith-Magee <russ...@keith-magee.com>
wrote:
Reply all
Reply to author
Forward
0 new messages