diff options
author | kxxoling <kxxoling@gmail.com> | 2016-07-13 14:47:50 +0800 |
---|---|---|
committer | kxxoling <kxxoling@gmail.com> | 2016-07-13 14:47:50 +0800 |
commit | 3d27216da43548681a2ca4374e8966de9408ac22 (patch) | |
tree | f2b4d948589fc933eb82b130f44038373b3dbf48 | |
parent | 495b46c731f94cf2ad3ed13eb013d395cc3932c3 (diff) | |
download | python-prettytable-ptable-3d27216da43548681a2ca4374e8966de9408ac22.tar.gz |
Fix failed tests
-rw-r--r-- | prettytable/prettytable.py | 8 | ||||
-rw-r--r-- | tests/test_prettytable.py | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/prettytable/prettytable.py b/prettytable/prettytable.py index bb6e16f..3b9bf27 100644 --- a/prettytable/prettytable.py +++ b/prettytable/prettytable.py @@ -472,14 +472,18 @@ class PrettyTable(object): Arguments: min_width - minimum width integer""" + if self.header: + fields = self._field_names + else: + fields = self._rows[0] if self._rows else [] result = { # minimum column width can't be lesser # than header's length name: max( - len(name), + _str_block_width(unicode_(name)), self._min_width.get(name, 0) ) - for name in self._field_names + for name in fields } return result diff --git a/tests/test_prettytable.py b/tests/test_prettytable.py index f28cfcd..8d353a7 100644 --- a/tests/test_prettytable.py +++ b/tests/test_prettytable.py @@ -697,22 +697,22 @@ class UnpaddedTableTest(unittest.TestCase): def testUnbordered(self): self.x.border = False result = self.x.get_string() - assert result.strip() == """ + self.assertEqual(result.strip(), """ abc def g.. -""".strip() +""".strip()) def testBordered(self): self.x.border = True result = self.x.get_string() - assert result.strip() == """ + self.assertEqual(result.strip(), """ +-+-+-+ |a|b|c| |d|e|f| |g|.|.| +-+-+-+ -""".strip() +""".strip()) if __name__ == "__main__": |