Fix issue with EvTable crop. Resolve #2761

This commit is contained in:
Griatch 2022-11-06 10:52:24 +01:00
parent 9438e5856a
commit cc6206db93
2 changed files with 39 additions and 18 deletions

View file

@ -224,7 +224,7 @@ class TestEvTable(EvenniaTestCase):
self._validate(expected, str(table))
def test_2762(self):
def test_direct_evcolumn_adds(self):
"""
Testing https://github.com/evennia/evennia/issues/2762
@ -276,3 +276,35 @@ class TestEvTable(EvenniaTestCase):
"""
self._validate(expected, str(table))
def test_width_enforcement(self):
"""
Testing https://github.com/evennia/evennia/issues/2761
EvTable enforces width kwarg, expanding the wrong column
"""
# simple crop
table = evtable.EvTable(table=[["column"]], width=7, enforce_size=True)
expected = """
+-----+
| col |
+-----+
"""
self._validate(expected, str(table))
colA = evtable.EvColumn("it", "is", "a", "column", width=6, enforce_size=True)
colB = evtable.EvColumn("and", "another", "column", "here")
table = evtable.EvTable(table=[colA, colB], width=40)
expected = """
+----+---------------------------------+
| it | and |
| is | another |
| a | column |
| co | here |
+----+---------------------------------+
"""
self._validate(expected, str(table))