Message225555
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. |
|
Date |
User |
Action |
Args |
2014-08-20 06:56:39 | Steven.Barker | set | recipients:
+ Steven.Barker, benjamin.peterson, Arfrever |
2014-08-20 06:56:39 | Steven.Barker | set | messageid: <1408517799.81.0.0142698680348.issue21389@psf.upfronthosting.co.za> |
2014-08-20 06:56:39 | Steven.Barker | link | issue21389 messages |
2014-08-20 06:56:39 | Steven.Barker | create | |
|