~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hashcache.py

[merge] update from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    start = int(time.time())
37
37
    while int(time.time()) == start:
38
38
        time.sleep(0.2)
 
39
 
 
40
 
 
41
class FixThisError(Exception):
 
42
    pass
39
43
    
40
44
 
41
45
class TestHashCache(TestCaseInTempDir):
118
122
        self.assertEquals(hc.hit_count, 1)
119
123
        self.assertEquals(hc.miss_count, 0)
120
124
        self.assertEquals(hc.get_sha1('foo2'), sha1('new content'))
 
125
 
 
126
    def test_hashcache_raise(self):
 
127
        """check that hashcache can raise BzrError"""
 
128
        from bzrlib.hashcache import HashCache
 
129
        import os
 
130
 
 
131
        os.mkdir('.bzr')
 
132
        hc = HashCache(u'.')
 
133
        ok = False
 
134
 
 
135
        # make a best effort to create a weird kind of file
 
136
        funcs = (os.mkfifo, os.mknod)
 
137
        for func in funcs:
 
138
            try:
 
139
                func('a')
 
140
                ok = True
 
141
                break
 
142
            except FixThisError:
 
143
                pass
 
144
 
 
145
        from bzrlib.errors import BzrError
 
146
        if ok:
 
147
            self.assertRaises(BzrError, hc.get_sha1, 'a')
 
148
        else:
 
149
            raise BzrError("no weird file type could be created: extend this test case for your os")