On 10/07/11 09:45, Ethan Furman wrote:
Tim Chase wrote:
On 10/07/11 07:38, Peter Otten wrote:
      def setUp(self):
          foo.window_date = functools.partial(foo.window_date,
around=date(2011, 1, 1))

it worked like a charm.

Another option is injection:

import foo

def window_date(...):
      ...

foo.window_date = window_date

The problem is that I *want* the functionality of the existing window_date() because that's part of what's being tested. Peter's suggestion of injection to the module namespace via functools.partial() to specify the missing parameter was the tip I needed to be able to write tests that exercised things properly without overly invasive changes to the code. But thanks for your idea.

-tkc


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to