[Answered ]-Django: tests.py adds project name to class

1πŸ‘

βœ…

The problem is manage.py. If you put django apps inside other packages you should use their fully qualified module name for imports and as a corrolary in INSTALLED_APPS.

It still works if you omit the parent package name, because manage.py temporarily hacks sys.path to import the module that contains the settings module. Then nose does its own import magic and is unable to reproduce the manage.py hack.

I’d recommend to use django-admin.py instead of manage.py as it does not do any import tricks.
There is no concept of a project in django. Just treat everything as plain python packages and control your PYTHONPATH.

πŸ‘€emulbreh

1πŸ‘

the inspect module is doing probably something hinky.

Python has the builtin function issubclass() for just this occasion!

def inherits_from_animal(some_animal):
    return issubclass(some_animal, Animal)

although i dont see why you couldnt just use issubclass wherever you are using inherits_from_animal now πŸ˜‰

πŸ‘€Thomas

Leave a comment