Steven Barker added the comment:

OK, I've written some tests of the new bound method repr functionality, which 
I'm attaching as a patch against the current tip.

I test the basic repr output, all the cases the old code got wrong (inherited 
methods, overridden methods, methods called via super, and classmethods) and 
the strange corner cases that probably won't come up in ordinary code (such as 
methods manually created from callables that don't have __name__ or 
__qualname__ attributes).

I've also fixed the defaultdict test that was relying upon the old repr output. 
I don't believe there are any other places in the standard library or tests 
where a bound method's repr is examined.

My patch adds the tests in a new file, Lib/test/test_bound_method_repr.py. I 
looked to see if there was an existing file that tested similar behavior, but 
none that I found really seemed appropriate. If I overlooked a better place to 
put the new tests, please let me know and I'll update the test patch.

I'm not very experienced at writing unit tests, so comments and/or criticism is 
welcomed. I copied parts of the file's structure (such as the test_main() 
function and if __name__ == "__main__" boilerplate) from other test files, so 
hopefully I've stayed pretty close to the usual Python test style.

----------
Added file: http://bugs.python.org/file36420/method_repr_tests.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21389>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to