# Bazaar on IronPython

Martin Pool mbp at sourcefrog.net
Fri Jul 3 00:05:57 BST 2009

2009/7/3 Martin (gzlist) <gzlist at googlemail.com>:
> On 01/07/2009, Martin Pool <mbp at sourcefrog.net> wrote:
>> You'd have to question too why littering multiple tests with finally
>> blocks is necessary.  We have methods like build_tree_contents and
>> should be calling that rather than having many tests duplicate it.
>>
>> Do you have a more specific case maybe?
>
> Well, I added the import gc; gc.collect() hack because I'd already
> made quite a few changes to file-lifetimes, and they were getting in
> the way of seeing other kinds of issues. To be more specific, see the
> attached selftest logs for one test suite file, with and without the
> forced collect (this is on the current patch, with the added
> cleanups). Not my call as to what's necessary, but dealing with it in
> the first place seems not to have been.

OK, so you have some of these:

Permission denied: unable to remove testing dir est_revert_conflicts_recursive
(16, "[Errno 16] The process cannot access the file
'C:\\temp\\testbzr-nanixf.tmp\\est_revert_conflicts_recursive\\work\\this-tree\\foo\\bar'
because it is being used by another
process.")...rkingtree.TestTreeDirectory.test_kind_character   OK
31ms

and I see some of them remain even after your change.

I think running gc.collect() after each test is a fairly reasonable
thing to do, at least on IronPython, to give better isolation between
tests.

The other problem we seem to have here is that there's actually no api
at the moment to force bzr to close a control object (eg repository).
It normally doesn't matter because we rarely use a great number of
them and they should be picked up soon by gc.  Perhaps there should
be.  On the other hand when you unlock it it should be releasing all
file handles and other resources, so this may not actually be a
problem.

One of the tests that was failing was

def test_get_file_with_stat_id_only(self):
# Explicit test to ensure we get a lstat value from WT4 trees.
tree = self.make_branch_and_tree('.')
self.build_tree(['foo'])
file_obj, statvalue = tree.get_file_with_stat('foo-id')
expected = os.lstat('foo')
self.assertEqualStat(expected, statvalue)