Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
nevermind
Browse files Browse the repository at this point in the history
  • Loading branch information
Robpol86 committed May 30, 2016
1 parent a3404a7 commit 7173c03
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 24 deletions.
13 changes: 0 additions & 13 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,4 @@

import py

MULTI_LINE = (
('Show', 'Characters'),
('Rugrats', 'Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\nDil Pickles'),
('South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick'),
)

PROJECT_ROOT = py.path.local(__file__).dirpath().join('..')

SINGLE_LINE = (
('Name', 'Color', 'Type'),
('Avocado', 'green', 'nut'),
('Tomato', 'red', 'fruit'),
('Lettuce', 'green', 'vegetable'),
)
14 changes: 13 additions & 1 deletion tests/test_ascii_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@
import pytest

from terminaltables.other_tables import AsciiTable
from tests import MULTI_LINE, SINGLE_LINE

SINGLE_LINE = (
('Name', 'Color', 'Type'),
('Avocado', 'green', 'nut'),
('Tomato', 'red', 'fruit'),
('Lettuce', 'green', 'vegetable'),
)

MULTI_LINE = (
('Show', 'Characters'),
('Rugrats', 'Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\nDil Pickles'),
('South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick'),
)


@pytest.fixture(autouse=True)
Expand Down
17 changes: 14 additions & 3 deletions tests/test_width_and_alignment/test_column_max_width.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest

from terminaltables.width_and_alignment import column_max_width, max_dimensions
from tests import MULTI_LINE, SINGLE_LINE


@pytest.fixture(autouse=True)
Expand All @@ -28,7 +27,13 @@ def test_empty():

def test_single_line():
"""Test with single-line cells."""
inner_widths = max_dimensions(SINGLE_LINE)[0]
table_data = [
['Name', 'Color', 'Type'],
['Avocado', 'green', 'nut'],
['Tomato', 'red', 'fruit'],
['Lettuce', 'green', 'vegetable'],
]
inner_widths = max_dimensions(table_data)[0]

# '| Lettuce | green | vegetable |'
outer, inner, padding = 2, 1, 2
Expand Down Expand Up @@ -85,7 +90,13 @@ def test_multi_line(monkeypatch):
:param monkeypatch: pytest fixture.
"""
inner_widths = max_dimensions(MULTI_LINE)[0]
table_data = [
['Show', 'Characters'],
['Rugrats', ('Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\n'
'Susie Carmichael, Dil Pickles, Kimi Finster, Spike')],
['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick']
]
inner_widths = max_dimensions(table_data)[0]
outer, inner, padding = 2, 1, 2

assert column_max_width(inner_widths, 0, outer, inner, padding) == -11
Expand Down
9 changes: 7 additions & 2 deletions tests/test_width_and_alignment/test_max_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from termcolor import colored

from terminaltables.width_and_alignment import max_dimensions
from tests import MULTI_LINE


@pytest.mark.parametrize('table_data,expected_w,expected_h', [
Expand Down Expand Up @@ -51,7 +50,13 @@ def test_multi_line():
]
assert max_dimensions(table_data, 0, 0, 1, 1) == ([3, 6], [3], [3, 6], [5])

assert max_dimensions(MULTI_LINE, 0, 0, 2, 2) == ([10, 83], [1, 2, 1], [10, 83], [5, 6, 5])
table_data = [
['Show', 'Characters'],
['Rugrats', ('Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\n'
'Susie Carmichael, Dil Pickles, Kimi Finster, Spike')],
['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick']
]
assert max_dimensions(table_data, 0, 0, 2, 2) == ([10, 83], [1, 2, 1], [10, 83], [5, 6, 5])


def test_trailing_newline():
Expand Down
22 changes: 17 additions & 5 deletions tests/test_width_and_alignment/test_table_width.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Test function in module."""

from terminaltables.width_and_alignment import max_dimensions, table_width
from tests import MULTI_LINE, SINGLE_LINE


def test_empty():
Expand All @@ -17,8 +16,15 @@ def test_empty():

def test_single_line():
"""Test with single-line cells."""
table_data = [
['Name', 'Color', 'Type'],
['Avocado', 'green', 'nut'],
['Tomato', 'red', 'fruit'],
['Lettuce', 'green', 'vegetable'],
]

# '| Lettuce | green | vegetable |'
outer, inner, outer_widths = 2, 1, max_dimensions(SINGLE_LINE, 1, 1)[2]
outer, inner, outer_widths = 2, 1, max_dimensions(table_data, 1, 1)[2]
assert table_width(outer_widths, outer, inner) == 31

# ' Lettuce | green | vegetable '
Expand All @@ -34,11 +40,11 @@ def test_single_line():
assert table_width(outer_widths, outer, inner) == 27

# '|Lettuce |green |vegetable |'
outer, inner, outer_widths = 2, 1, max_dimensions(SINGLE_LINE, 1)[2]
outer, inner, outer_widths = 2, 1, max_dimensions(table_data, 1)[2]
assert table_width(outer_widths, outer, inner) == 28

# '|Lettuce |green |vegetable |'
outer_widths = max_dimensions(SINGLE_LINE, 3, 2)[2]
outer_widths = max_dimensions(table_data, 3, 2)[2]
assert table_width(outer_widths, outer, inner) == 40

table_data = [
Expand All @@ -54,5 +60,11 @@ def test_single_line():

def test_multi_line():
"""Test with multi-line cells."""
outer, inner, outer_widths = 2, 1, max_dimensions(MULTI_LINE, 1, 1)[2]
table_data = [
['Show', 'Characters'],
['Rugrats', ('Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\n'
'Susie Carmichael, Dil Pickles, Kimi Finster, Spike')],
['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick']
]
outer, inner, outer_widths = 2, 1, max_dimensions(table_data, 1, 1)[2]
assert table_width(outer_widths, outer, inner) == 100

0 comments on commit 7173c03

Please sign in to comment.