File: tests_itertools.py

package info (click to toggle)
tqdm 4.67.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 744 kB
  • sloc: python: 5,621; makefile: 159; sh: 16
file content (26 lines) | stat: -rw-r--r-- 628 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Tests for `tqdm.contrib.itertools`.
"""
import itertools as it

from tqdm.contrib.itertools import product

from .tests_tqdm import StringIO, closing


class NoLenIter(object):
    def __init__(self, iterable):
        self._it = iterable

    def __iter__(self):
        for i in self._it:
            yield i


def test_product():
    """Test contrib.itertools.product"""
    with closing(StringIO()) as our_file:
        a = range(9)
        assert list(product(a, a[::-1], file=our_file)) == list(it.product(a, a[::-1]))

        assert list(product(a, NoLenIter(a), file=our_file)) == list(it.product(a, NoLenIter(a)))