[rfc] [patch] small cleanups
Denys Duchier
duchier at ps.uni-sb.de
Wed Jan 11 23:24:29 GMT 2006
John Arbash Meinel <john at arbash-meinel.com> writes:
> for func in (os.mkfifo, os.mknod, os.mkdev):
hmm... that won't work if these functions don't exists (already a bug in my test
catching just OSError - I knew I would forget something when going to non bare
except). How about this instead:
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
# make a best effort to create a weird kind of file
these = ((os,("mkfifo",),('a',)),
(os,("mknod" ,),('a',)),
(os,("mkdev" ,),('a',)))
for mod, attrs, args in these:
x = mod
for a in attrs:
if hasattr(x,a):
x = getattr(x,a)
else:
x = None
break
if x is None:
continue
try:
x(*args)
ok=True
except OSError:
pass
from bzrlib.errors import BzrError
if ok:
self.assertRaises(BzrError, hc.get_sha1, 'a')
else:
raise BzrError("no weird file type could be created: extend this test case for your os")
--Denys
More information about the bazaar
mailing list