PQM: test failure
John Arbash Meinel
john at arbash-meinel.com
Thu Apr 5 22:31:39 BST 2007
Andrew Bennetts wrote:
> John Arbash Meinel wrote:
>> Olexandr Byelchenko wrote:
>>> FAIL: test_known_failure_ok_run (bzrlib.tests.test_selftest.TestRunner)
>> ...
>>> I think it's a very bad style to make test depends on time intervals.
>>>
>>> [µ]
>>>
>>>
>> I don't think it was meant to be dependent on time interval. So we could
>> instead use:
>> self.assertContainsRe(stream.getvalue(),
>> '\n'
>> '-*\n'
>> 'Ran 1 test in 0.0\\d\\ds\n'
>> '\n'
>> 'OK \\(known_failures=1\\)\n')
>>
>> It works for me, at least.
>> (the \\ are a little ugly, but necessary since we need \n)
>
> You version is still dependent on the time interval, even though it's more
> permissive than the current version.
>
> Why not: 'Ran 1 test in .*s\n'? That way it will match precisely
> what matters, and no more. You could make it check for "\\d+.\\d{3}", but
> that's not the point of this test. Time reporting is (or at least should be)
> tested elsewhere. This test is to verify that a known failure is reported in
> the final output.
>
> Keep the test simple, and keep it focussed one doing just one thing (and doing
> it well).
>
> -Andrew.
As I didn't write the original test, I was being conservative. But I
have no problem with:
Ran 1 test in .*\n
Though what is the test actually testing for, then. I think it is just
the 'known_failures=1' line. Which means we should realy change it to
self.assertContainsRe(stream.getvalue(), r'\(known_failures=1\)')
And then we don't have to worry about anything else.
John
=:->
More information about the bazaar
mailing list