Some classes use __getattr__ to automatically create requested attributes. The recent trend of LINQ-like query objects is what I ran into. This confuses the pretty-printing machinery that tests for _repr_pretty_. This pull request fixes many of these problems by simply testing if the _repr_pretty_ attribute is callable. This may still be confused by certain mocking frameworks, but it's a good start.
BUG: Fix pretty-printing for overzealous objects that will return som…
…ething non-callable for any requested attribute (thus confusing hasattr).
Looks clean and sensible to me. Can you name a few libraries that do this sort of thing? Perhaps Pyro, etc. Maybe we can run some extra tests if some of these libraries are present.
http://pypi.python.org/pypi/underverse is the one I was using when I ran into the problem.
We've also had completion issues with these libraries. It would be useful to give a few tests so that future changes will be caught. But for now, I think this can just be merged, unless you want to write a simple test with underverse now.
I added a test with a badly-formed _repr_pretty_ attribute. I could write one with a __getattr__ that returns a generator for greater verisimilitude, but I'm not sure what else that would catch that the current test doesn't.