diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fixtures/multiline-cells.txt | 6 | ||||
-rw-r--r-- | tests/test_rst_tables.py | 18 |
2 files changed, 20 insertions, 4 deletions
diff --git a/tests/fixtures/multiline-cells.txt b/tests/fixtures/multiline-cells.txt new file mode 100644 index 0000000..78465fd --- /dev/null +++ b/tests/fixtures/multiline-cells.txt @@ -0,0 +1,6 @@ +Feature| Description | +Ease of use | Drop dead simple! +| Foo | Bar, qux, mux| +Predictability | Lorem ipsum dolor sit amet, consectetur adipiscing elit. | +| | Nullam congue dapibus aliquet. Integer ut rhoncus leo. In hac +| | habitasse platea dictumst. Phasellus pretium iaculis. diff --git a/tests/test_rst_tables.py b/tests/test_rst_tables.py index 1eb61a6..0517769 100644 --- a/tests/test_rst_tables.py +++ b/tests/test_rst_tables.py @@ -22,7 +22,7 @@ import unittest # Load test subjects from rst_tables import get_table_bounds, create_table, parse_table, \ draw_table, table_line, get_column_widths, \ - pad_fields + pad_fields, unify_table class TestRSTTableFormatter(unittest.TestCase): @@ -75,6 +75,16 @@ class TestRSTTableFormatter(unittest.TestCase): expected = [['x', 'y', ''], ['a', 'b', 'c'], ['only one', '', '']] self.assertEquals(expected, parse_table(input)) + def testUnifyTables(self): + input = [[' x ', ' y'], ['xxx', ' yyyy ', 'zz']] + expected = [[' x ', ' y', ''], ['xxx', ' yyyy ', 'zz']] + self.assertEquals(expected, unify_table(input)) + + def testUnifyTablesRemovesEmptyColumns(self): + input = [['x', '', 'y'], ['xxx', '', 'yyyy', 'zz', ' ']] + expected = [['x', 'y', ''], ['xxx', 'yyyy', 'zz']] + self.assertEquals(expected, unify_table(input)) + def testParseDealsWithSpacesAtLineEnd(self): input = ['x y ', 'a b ', 'only one'] expected = [['x', 'y'], ['a', 'b'], ['only one', '']] @@ -107,9 +117,9 @@ class TestRSTTableFormatter(unittest.TestCase): '| x | This became somewhat larger |', 'blah | A new line|| ', '+-----+----+'] - expect = [['Foo', 'Mu', ''], - ['x', 'This became somewhat larger', ''], - ['blah', 'A new line', '']] + expect = [['Foo', 'Mu'], + ['x', 'This became somewhat larger'], + ['blah', 'A new line']] self.assertEquals(expect, parse_table(input)) def testTableLine(self): |