[Python-Dev] Using logging in the stdlib and its unit tests

Brett Cannon brett at python.org
Wed Dec 8 00:03:47 CET 2010


On Tue, Dec 7, 2010 at 13:57, Eric Smith <eric at trueblade.com> wrote:
> On 12/07/2010 03:26 PM, Vinay Sajip wrote:
>>
>> I would suggest that when unit testing, rather than adding StreamHandlers
>> to log
>> to stderr, that something like TestHandler and Matcher from this post:
>>
>> http://plumberjack.blogspot.com/2010/09/unit-testing-and-logging.html
>>
>> This will allow assertion checking of logged messages without resorting to
>> StringIO, getvalue() etc. If people think it's a good idea, I can add the
>> TestHandler/Matcher classes to the unit test infrastructure (they wouldn't
>> become part of the public API, at least until 3.3, but I presume they
>> could be
>> used in the stdlib unit tests).
>
> Wouldn't it make more sense to add these to test.support? I don't think we
> make any guarantees about its API being stable, although I have a faint
> recollection of that being debated in the past.

We make no guarantees. The debate was whether we accidentally painted
ourselves into a corner by documenting the module a tad for core
developer's benefit. The warning has been made much more explicit in
the docs that test.support is not meant for outside usage.


More information about the Python-Dev mailing list