Esempio n. 1
0
    def test_cache_limit(self):
        counter = Counter()
        for i in range(0, 100):
            counter.echo(i)  # called
            counter.echo(i)  # cached
            assert_that(self.cache_len(counter, Counter.echo), is_(i + 1))
        assert_that(counter.count, is_(100))
        assert_that(self.cache_len(counter, Counter.echo), is_(100))

        for i in range(100, 200):
            counter.echo(i)  # called
            counter.echo(i)  # cached
            assert_that(len(_get_cache_dict(counter, Counter.echo)), is_(100))
        assert_that(counter.count, is_(100 + 100))
Esempio n. 2
0
    def test_cache_limit(self):
        counter = Counter()
        for i in range(0, 100):
            counter.echo(i)  # called
            counter.echo(i)  # cached
            assert_that(self.cache_len(counter, Counter.echo), is_(i+1))
        assert_that(counter.count, is_(100))
        assert_that(self.cache_len(counter, Counter.echo), is_(100))

        for i in range(100, 200):
            counter.echo(i)  # called
            counter.echo(i)  # cached
            assert_that(len(_get_cache_dict(counter, Counter.echo)), is_(100))
        assert_that(counter.count, is_(100+100))
Esempio n. 3
0
 def cache_len(self, obj, func):
     return len(_get_cache_dict(obj, func))
Esempio n. 4
0
 def cache_len(self, obj, func):
     return len(_get_cache_dict(obj, func))