Mercurial > public > mercurial-scm > hg
comparison tests/test-filecache.py @ 31284:74cbbd5420ba
filecache: explicitly test 'repofilecache'
The tests is actually about testing a repofilecache (it uses a fake repo). We
make this clear to prevent blockers while cleaning theses API.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Wed, 08 Mar 2017 16:43:16 -0800 |
parents | 34d57ddaf9f2 |
children | daa5f47558cf |
comparison
equal
deleted
inserted
replaced
31283:f84b0e926eb2 | 31284:74cbbd5420ba |
---|---|
8 sys.exit(80) | 8 sys.exit(80) |
9 | 9 |
10 from mercurial import ( | 10 from mercurial import ( |
11 extensions, | 11 extensions, |
12 hg, | 12 hg, |
13 scmutil, | 13 localrepo, |
14 ui as uimod, | 14 ui as uimod, |
15 util, | 15 util, |
16 vfs as vfsmod, | 16 vfs as vfsmod, |
17 ) | 17 ) |
18 | 18 |
19 filecache = scmutil.filecache | |
20 | |
21 class fakerepo(object): | 19 class fakerepo(object): |
22 def __init__(self): | 20 def __init__(self): |
23 self._filecache = {} | 21 self._filecache = {} |
24 | 22 |
25 def join(self, p): | 23 class fakevfs(object): |
26 return p | 24 |
25 def join(self, p): | |
26 return p | |
27 | |
28 vfs = fakevfs() | |
29 | |
30 def unfiltered(self): | |
31 return self | |
27 | 32 |
28 def sjoin(self, p): | 33 def sjoin(self, p): |
29 return p | 34 return p |
30 | 35 |
31 @filecache('x', 'y') | 36 @localrepo.repofilecache('x', 'y') |
32 def cached(self): | 37 def cached(self): |
33 print('creating') | 38 print('creating') |
34 return 'string from function' | 39 return 'string from function' |
35 | 40 |
36 def invalidate(self): | 41 def invalidate(self): |