Debian Codegraph @

t/unit/utils/test_utils.py

raw
1 import pytest
2
3 from celery.utils import cached_property, chunks
4
5
6 @pytest.mark.parametrize('items,n,expected', [
7 (range(11), 2, [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10]]),
8 (range(11), 3, [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10]]),
9 (range(10), 2, [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]),
10 ])
11 def test_chunks(items, n, expected):
12 x = chunks(iter(list(items)), n)
13 assert list(x) == expected
14
15
16 def test_cached_property():
17
18 def fun(obj):
19 return fun.value
20
21 x = cached_property(fun)
22 assert x.__get__(None) is x
23 assert x.__set__(None, None) is x
24 assert x.__delete__(None) is x