diff --git a/src/tablib/formats/_rst.py b/src/tablib/formats/_rst.py index 9e2cc73c..793bce9d 100644 --- a/src/tablib/formats/_rst.py +++ b/src/tablib/formats/_rst.py @@ -113,7 +113,7 @@ def export_set_as_simple_table(cls, dataset, column_widths=None): lines = [] wrapper = TextWrapper() if column_widths is None: - column_widths = _get_column_widths(dataset, pad_len=2) + column_widths = cls._get_column_widths(dataset, pad_len=2) border = ' '.join(['=' * w for w in column_widths]) lines.append(border) diff --git a/tests/test_tablib.py b/tests/test_tablib.py index fe793df7..72f5163d 100755 --- a/tests/test_tablib.py +++ b/tests/test_tablib.py @@ -660,6 +660,28 @@ def test_empty_string(self): '========== ========= ===' ) + def test_rst_export_set(self): + # Arrange + data = tablib.Dataset() + data.append(self.john) + data.headers = self.headers + fmt = registry.get_format("rst") + + # Act + out1 = fmt.export_set(data) + out2 = fmt.export_set_as_simple_table(data) + + # Assert + self.assertEqual(out1, out2) + self.assertEqual( + out1, + "========== ========= ===\n" + "first_name last_name gpa\n" + "========== ========= ===\n" + "John Adams 90 \n" + "========== ========= ===", + ) + class CSVTests(BaseTestCase): def test_csv_format_detect(self):