selftest.backtick versus selftest.run_bzr
John A Meinel
john at arbash-meinel.com
Sat Sep 17 19:02:47 BST 2005
David Clymer wrote:
> On Sat, 2005-09-17 at 12:09 -0400, John A Meinel wrote:
>>I'm trying to write some more test cases. These are supposed to be
>>external tests (as in making sure that the cmd_* functions are working
>>correctly from the outside).
>>>From what I can tell, there are 2 convenience functions to consider,
>>self.backtick() and self.run_bzr(). run_bzr() actually just invokes the
>>in-memory bzr library (which I am okay with), but I can't find a way to
>>get the output of the command.
> I think there is an example of capturing output from run_bzr in
> TestCase.test_add_reports() in blackbox.py using self.apply_redirected()
Thanks. I guess I was wondering why something like that was not already
>>Am I missing a flag? Or should self.run_bzr be updated to support the
>>"backtick=True" statement like the blackbox.py tests use? Or should I be
>>subclassing the blackbox testing class instead of just TestCaseInTempDir?
> I would think that if you are looking at the output of the command, this
> would be a blackbox test, in which case you probably want to be using
> ExternalBase and self.runbzr(). Is there a particular reason not to use
> the external testing class?
Yes and no. There was a discussion recently that it is easier to debug
test failures if it does not actually spawn a new command. (Because you
can get nice stack traces, etc).
Also, there is quite a bit of overhead of spawning a new instance.
Loading all of the python code is not free. On my Mac, "time bzr root"
takes 0.6 seconds. But doing:
b = bzrlib.branch.Branch.open_containing('.')
Takes only 0.005 seconds.
So if you can re-use the already loaded bzrlib, then the tests can run
much much faster.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 253 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050917/974275e3/attachment.pgp
More information about the bazaar