Fix NameError: name '_get_column_widths' is not defined (#433)

* Fix NameError: name '_get_column_widths' is not defined

* Also test ReSTFormat.export_set
This commit is contained in:
Hugo van Kemenade
2019-11-12 10:53:20 +02:00
committed by GitHub
parent 357a5594c5
commit 57a535f577
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ class ReSTFormat:
lines = [] lines = []
wrapper = TextWrapper() wrapper = TextWrapper()
if column_widths is None: 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]) border = ' '.join(['=' * w for w in column_widths])
lines.append(border) lines.append(border)
+22
View File
@@ -660,6 +660,28 @@ class RSTTests(BaseTestCase):
'========== ========= ===' '========== ========= ==='
) )
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): class CSVTests(BaseTestCase):
def test_csv_format_detect(self): def test_csv_format_detect(self):