Thanks -- I didn't know about mock objects, and this is good to know.
But this doesn't feel like this is the solution I'm looking for.  It's
a large project, and your proposal would require extensive patching.

Is the solution to create a new testrunner that sets a different
environment (with different settings) for each app?  Is there another
way to fool a testcase into thinking that an app has not been
installed?

Thanks again,

Cody



On Feb 17, 2:00 pm, Phlip <phlip2...@gmail.com> wrote:
> On Feb 17, 12:03 pm, Cody Django <codydja...@gmail.com> wrote:
>
> > For example, I have a captcha that is used in parts of a site that
> > affects form logic.
> > The django settings has a variable CAPTCHA = True, which acts as a
> > switch.
>
> > I'd like to change this setting in the setup for each TestCase.
>
> You should use a mock object, to fake a-priori things like stochastic
> user input.
>
> Python's mock library has a 'patch.object' feature which mocks a
> method on a class, even before objects of that class are instantiated.
>
> In most of your setUp calls, patch the captcha handler to trivially
> pass it, without real user input.
>
> To test the captcha, mock it to pass or fail.
>
> --
>   Phlip
>  http://c2.com/cgi/wiki?ZeekLand

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

Reply via email to