[rfc] [patch] small cleanups
John Arbash Meinel
john at arbash-meinel.com
Wed Jan 11 21:41:39 GMT 2006
Denys Duchier wrote:
> Aaron Bentley <aaron.bentley at utoronto.ca> writes:
>
>
>>Looks good. Can we have a test that HashCache.get_sha1 can raise BzrError?
>
>
> from my bzr.tests branch at:
>
> http://delta.univ-orleans.fr/~duchier/bzr/bzr.tests
>
> careful! you need the cleanup fix otherwise obviously the test bombs because
> BzrError is unknown in hashcache.py
>
> ------------------------------------------------------------
> revno: 1496
> committer: Denys Duchier <denys.duchier at mozart-oz.org>
> branch nick: bzr.tests
> timestamp: Wed 2006-01-11 21:15:05 +0100
> message:
> check that hashcache can raise BzrError
>
>
>
>
> ------------------------------------------------------------------------
>
> === modified file 'bzrlib/hashcache.py'
> --- bzrlib/hashcache.py
> +++ bzrlib/hashcache.py
> @@ -36,7 +36,6 @@
> from bzrlib.trace import mutter, warning
> from bzrlib.atomicfile import AtomicFile
> from bzrlib.osutils import pathjoin
> -
>
> FP_MODE_COLUMN = 5
>
>
> === modified file 'bzrlib/tests/test_hashcache.py'
> --- bzrlib/tests/test_hashcache.py
> +++ bzrlib/tests/test_hashcache.py
> @@ -118,3 +118,30 @@
> self.assertEquals(hc.hit_count, 1)
> self.assertEquals(hc.miss_count, 0)
> self.assertEquals(hc.get_sha1('foo2'), sha1('new content'))
> +
> + def test_hashcache_raise(self):
> + """check that hashcache can raise BzrError"""
> + from bzrlib.hashcache import HashCache
> + import os
> +
> + os.mkdir('.bzr')
> + hc = HashCache(u'.')
> + ok = False
> + try:
> + os.mkfifo('a')
> + ok=True
> + except:
> + try:
> + os.mknod('a')
> + ok=True
> + except:
> + try:
> + os.mkdev('a')
> + ok=True
> + except:
> + pass
> + if ok:
> + from bzrlib.errors import BzrError
> + def check():
> + return hc.get_sha1('a')
> + self.assertRaises(BzrError, check)
>
Why can't you just do:
self.assertRaises(BzrError, hc.get_sha1, 'a')
I'm guessing you just didn't see how to pass parameters.
With that fixed, I'm +1 on the cleanups. I've merged everything but the
test. (your revno 1500, jam-integration revno 1502)
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060111/60f1619a/attachment.pgp
More information about the bazaar
mailing list