diff --git a/terminaltables/width_and_alignment.py b/terminaltables/width_and_alignment.py index 326fd5a..88180b4 100644 --- a/terminaltables/width_and_alignment.py +++ b/terminaltables/width_and_alignment.py @@ -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) diff --git a/tests/test_width_and_alignment_max_dimensions.py b/tests/test_width_and_alignment_max_dimensions.py index 73540e8..3d5493a 100644 --- a/tests/test_width_and_alignment_max_dimensions.py +++ b/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]), @@ -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])