News for hackers. Stuff that matters.
Re:Super Simple Mocking For Python by MBlume on Wednesday February 22, 2012 @11:46PM (#3623835)
At risk of bikeshedding, I think the "most pythonic" approach would be mock(obj, x=1, y=2)

Seriously though, cool lib, thanks for it =)

Re:Super Simple Mocking For Python by jacobolus on Thursday February 23, 2012 @01:53AM (#3624071)
Yes, the most pythonic is:

  mock(obj, x=1, y=2)
Which you get by:

  def __init__(self, obj, **mocks):
      self.obj = obj
      self.mocks = mocks
This can then also be called (using the built-in double-star-unpacking feature) as:

  mock(obj, **{'x': 1, 'y': 2})
or even

  mock(obj, **dict([('x', 1), ('y', 2)]))
Then there’s no explicit need to support multiple alternative function signatures, and in particular you don’t get people using the (quite atypical and therefore semantically ambiguous):

  mock(obj, 'x', 1, 'y', 2).
Re:Super Simple Mocking For Python by tebeka on Thursday February 23, 2012 @09:50PM (#3627787)
Thanks, updated the code to use keyword arguments only.