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

Commit

Permalink
Color, one less if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Robpol86 committed May 15, 2016
1 parent 8b49081 commit d654ad6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 0 additions & 3 deletions terminaltables/width_and_alignment.py
Expand Up @@ -84,9 +84,6 @@ def max_dimensions(table_data):
:return: 2-item tuple of n-item lists. Column widths and row heights.
:rtype: tuple
"""
if not table_data:
return list(), list()

widths = [0] * max(len(r) for r in table_data)
heights = [0] * len(table_data)

Expand Down
15 changes: 13 additions & 2 deletions tests/test_width_and_alignment_max_dimensions.py
@@ -1,13 +1,14 @@
"""Test function in module."""

import pytest
from colorama import Fore
from colorclass import Color
from termcolor import colored

from terminaltables.width_and_alignment import max_dimensions


@pytest.mark.parametrize('table_data,expected_w,expected_h', [
([], [], []),
([[]], [], [0]),
([['']], [0], [0]),
([['', '']], [0, 0], [0]),
Expand Down Expand Up @@ -67,3 +68,13 @@ def test_trailing_newline():
['\nRow Four'],
]
assert max_dimensions(table_data) == ([9], [2, 2, 2, 2])


def test_colors_cjk_rtl():
"""Test color text, CJK characters, and RTL characters."""
table_data = [
[Color(u'{blue}Test{/blue}')],
[Fore.BLUE + u'Test' + Fore.RESET],
[colored(u'Test', 'blue')],
]
assert max_dimensions(table_data) == ([4], [1, 1, 1])

0 comments on commit d654ad6

Please sign in to comment.