Skip to content

Instantly share code, notes, and snippets.

@k-bx
Created May 4, 2012 19:14
Show Gist options
  • Save k-bx/2597106 to your computer and use it in GitHub Desktop.
Save k-bx/2597106 to your computer and use it in GitHub Desktop.
mock descriptor issue
from mock import patch
class RealOne(object):
def quack(self):
print '> quack'
class BarDescriptor(object):
def __get__(self, obj, type=None):
real = RealOne()
return real
class Foo(object):
bar = BarDescriptor()
with patch('__main__.Foo.bar', autospec=True):
print '> Foo.bar:', Foo.bar
print '> quack:', Foo.bar.quack()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment