Commits

Miki Tebeka committed 8d4404d

Use **kw

Comments (0)

Files changed (1)

 
             def test_get_data():
                 expected = 'Mary had a little lamb'
-                with mock(foo, 'urlopen', lambda url: StringIO(expected)):
+                with mock(foo, urlopen=lambda url: StringIO(expected)):
                     result = foo.get_data('http://google.com')
                 assert result == expected, 'bad data'
     '''
-    def __init__(self, obj, *args):
+    def __init__(self, obj, **kw):
         '''Create mock object
             obj - Object to be mocked
-            args - What to mock, can be either a list of ('attr', value) or a
-                   dictionary.
+            kw - Mocked attributes
         '''
         self.obj = obj
-        if len(args) > 1:
-            self.mocks = dict(zip(args[::2], args[1::2]))
-        else:
-            self.mocks = args[0]
+        self.mocks = kw.copy()
 
     def __enter__(self):
         self.orig = self.obj.__dict__.copy()