~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testhashcache.py

  • Committer: Martin Pool
  • Date: 2005-08-04 21:39:23 UTC
  • Revision ID: mbp@sourcefrog.net-20050804213923-aaf986c9c9a29506
- merge bzrlib.revision.is_ancestor from aaron

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
import os
18
 
import sys
19
 
import time
20
 
from bzrlib.tests import TestCaseInTempDir
 
17
from bzrlib.selftest import InTempDir
21
18
 
22
19
 
23
20
 
27
24
 
28
25
 
29
26
def pause():
30
 
    if False:
31
 
        return
32
 
    if sys.platform in ('win32', 'cygwin'):
33
 
        time.sleep(3)
34
 
        return
 
27
    import time
35
28
    # allow it to stabilize
36
29
    start = int(time.time())
37
30
    while int(time.time()) == start:
38
31
        time.sleep(0.2)
39
32
    
40
33
 
41
 
class TestHashCache(TestCaseInTempDir):
42
34
 
43
 
    def test_hashcache(self):
44
 
        """Functional tests for hashcache"""
 
35
class TestHashCache(InTempDir):
 
36
    """Functional tests for hashcache"""
 
37
    def runTest(self):
45
38
        from bzrlib.hashcache import HashCache
46
39
        import os
 
40
        import time
47
41
 
48
42
        # make a dummy bzr directory just to hold the cache
49
43
        os.mkdir('.bzr')
50
 
        hc = HashCache(u'.')
 
44
        hc = HashCache('.')
51
45
 
52
46
        file('foo', 'wb').write('hello')
53
47
        os.mkdir('subdir')
110
104
        hc.write()
111
105
        del hc
112
106
 
113
 
        hc = HashCache(u'.')
 
107
        hc = HashCache('.')
114
108
        hc.read()
115
109
 
116
110
        self.assertEquals(len(hc._cache), 2)
118
112
        self.assertEquals(hc.hit_count, 1)
119
113
        self.assertEquals(hc.miss_count, 0)
120
114
        self.assertEquals(hc.get_sha1('foo2'), sha1('new content'))
 
115
 
 
116
        
 
117
 
 
118
        
 
119