All,

I have an abstract base class for which I'm wishing to write some in-
line doctests. I have read ticket http://code.djangoproject.com/ticket/8108
which addresses it, but I'm hoping to find a work-around.

In the snip below, I want to test the Base.__unicode__() method
without writing a doctest using one of the defined derived classes,
reason being I don't wish the doctest for Base.__unicode__() to be
dependent upon a subclass.

models.py
---

class Base:
  def __unicode__(self):
    return u"Test"
  class Meta:
    abstract = True

class Derived (Base):
  class Meta:
    db_table = "derived"

Simulating a doctest from the shell:

>>> from myapp.models import Base
>>> class BaseTest (Base): pass
...
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 53, in __new__
    kwargs = {"app_label": model_module.__name__.split('.')[-2]}
IndexError: list index out of range

How best to accomplish this?

Franco

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

Reply via email to