Wednesday, July 18, 2012

Re: Unit test an app using ContentType?

Here's a clue from Carl Meyer in an old Stackoverflow post:

http://stackoverflow.com/questions/502916/django-how-to-create-a-model-dynamically-just-for-testing

The idea here is to put additional models in
myapp/tests/models.py and then include myapp.tests in
INSTALLED_APPS when testing. This might do the trick for me.

Aron

Aron Griffis wrote: [Wed Jul 18 2012, 03:52:43PM EDT]
> Hello,
>
> I've written a generic app that uses the ContentType framework.
> It's not designed to be used on its own, rather it plugs into an
> existing project, and then my other apps call a registration
> function. It's working well for me, but I'd like to write
> standalone unit tests and I'm not sure how.
>
> The problem is that there's only one model in this app, and it's
> the one that uses ContentType, so there are no other models with
> which to test it unless I involve an extra app. How does one
> write unit tests for a model that uses ContentType? Is there
> a way to put test-only models into tests.py?
>
> Thanks,
> Aron

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment