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

Commit

Permalink
works
Browse files Browse the repository at this point in the history
  • Loading branch information
Robpol86 committed May 16, 2016
1 parent fbc4338 commit b68c471
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tests/test_max_width.py
@@ -1,7 +1,5 @@
"""Test max width of table in a terminal without wrapping."""

from textwrap import dedent

import pytest

from terminaltables.tables import AsciiTable, UnixTable
Expand Down Expand Up @@ -103,8 +101,8 @@ def test_multi_line(monkeypatch, cls):
"""Test multi-line tables."""
table_data = [
['Show', 'Characters'],
['Rugrats', dedent('Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\n'
'Susie Carmichael, Dil Pickles, Kimi Finster, Spike')],
['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']
]
table = cls(table_data)
Expand Down
23 changes: 23 additions & 0 deletions tests/test_width_and_alignment/test_column_max_width.py
Expand Up @@ -80,3 +80,26 @@ def test_single_line(monkeypatch):
assert column_max_width(table_data, 0, outer, inner, padding) == 55
assert column_max_width(table_data, 1, outer, inner, padding) == 50
assert column_max_width(table_data, 2, outer, inner, padding) == 54


def test_multi_line(monkeypatch):
"""Test with multi-line cells.
:param monkeypatch: pytest fixture.
"""
monkeypatch.setattr('terminaltables.width_and_alignment.terminal_size', lambda: (79, 24))

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, padding = 2, 1, 2

assert column_max_width(table_data, 0, outer, inner, padding) == -11
assert column_max_width(table_data, 1, outer, inner, padding) == 62

monkeypatch.setattr('terminaltables.width_and_alignment.terminal_size', lambda: (100, 24))
assert column_max_width(table_data, 0, outer, inner, padding) == 10
assert column_max_width(table_data, 1, outer, inner, padding) == 83

0 comments on commit b68c471

Please sign in to comment.