File size: 311 Bytes
079c32c
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import pytest

from ding.utils.collection_helper import iter_mapping


@pytest.mark.unittest
class TestCollectionHelper:

    def test_iter_mapping(self):
        _iter = iter_mapping([1, 2, 3, 4, 5], lambda x: x ** 2)

        assert not isinstance(_iter, list)
        assert list(_iter) == [1, 4, 9, 16, 25]