Skip to content

Commit

Permalink
Fix failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kxxoling committed Jul 13, 2016
1 parent 495b46c commit 3d27216
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions prettytable/prettytable.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,18 @@ def min_width(self):
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

Expand Down
8 changes: 4 additions & 4 deletions tests/test_prettytable.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,22 +697,22 @@ def setUp(self):
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__":
Expand Down

0 comments on commit 3d27216

Please sign in to comment.