summaryrefslogtreecommitdiffstats
path: root/tests/test_build/test_combine.py
blob: b296ffd2e4d63c5de4d06ef5fc0dbe27f16ac3d1 (plain)
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
27
28
29
30
31
32
33
34
35
36
37
"""Test function in module."""

import pytest

from terminaltables.build import combine


@pytest.mark.parametrize('generator', [False, True])
def test_borders(generator):
    """Test with borders.

    :param bool generator: Test with generator instead of list.
    """
    line = ['One', 'Two', 'Three']
    actual = list(combine(iter(line) if generator else line, '>', '|', '<'))
    assert actual == ['>', 'One', '|', 'Two', '|', 'Three', '<']


@pytest.mark.parametrize('generator', [False, True])
def test_no_border(generator):
    """Test without borders.

    :param bool generator: Test with generator instead of list.
    """
    line = ['One', 'Two', 'Three']
    actual = list(combine(iter(line) if generator else line, '', '', ''))
    assert actual == ['One', 'Two', 'Three']


@pytest.mark.parametrize('generator', [False, True])
def test_no_items(generator):
    """Test with empty list.

    :param bool generator: Test with generator instead of list.
    """
    actual = list(combine(iter([]) if generator else [], '>', '|', '<'))
    assert actual == ['>', '<']