[merge][#124153][#124849] clean up capturing logging from within tests
Martin Pool
mbp at sourcefrog.net
Tue Jan 22 22:44:11 GMT 2008
On 23/01/2008, John Arbash Meinel <john at arbash-meinel.com> wrote:
> The concept seems good, and I didn't see anything bad in the code. But I
> didn't see any tests that the push and pop work properly either. I think
> it would be good to add a test that:
>
> trace.mutter('foo')
> token1 = trace.push_log_file('my-test-file.log')
> trace.mutter('bar')
> token2 = trace.push_log_file('another-test-file.log')
> trace.mutter('baz')
> trace.pop_log_file(token2)
> trace.mutter('fizzle')
> trace.pop_log_file(token1)
> trace.mutter('frazzle')
>
> self.check_file_contents('my-test-file.log', 'bar\nfizzle\n')
> self.check_file_contents('another-test-file.log', 'baz\n')
>
> We would need to be careful, because you open the file in "at" so we
> need to translate the line endings on Windows.
There are some tests that the test case framework does redirect
messages. But you're right, it would be good to exercise them
directly.
Thanks
--
Martin
More information about the bazaar
mailing list