PQM: test failure
Andrew Bennetts
andrew at canonical.com
Tue Apr 3 01:29:18 BST 2007
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.
More information about the bazaar
mailing list