[patch] hashcache fixes
Andrew Bennetts
andrew at canonical.com
Mon Jul 10 12:37:18 BST 2006
On Mon, Jul 10, 2006 at 04:59:05PM +1000, Andrew Bennetts wrote:
[...]
> Looking at the problem from a strict testability point of view, this suggests
> the code isn't factored well enough. What if the _fingerprint function was a
> method of HashCache objects instead, so test cases can override it to return
> modified results -- e.g.:
It occurs to me that to completely factor out external stuff that we can't
control, the same principle applies to the use of time.time(). Hashcache could
have a "now" method that just does "return time.time()", and tests could
override it. This way tests can completely control all the variables involved
in get_sha1, and thus test all the logic deterministically.
-Andrew.
More information about the bazaar
mailing list