From 630f378e6564363d0faf899d15f0e2c2156465ae Mon Sep 17 00:00:00 2001 From: moltenmuffins Date: Thu, 8 Oct 2020 16:31:31 +0800 Subject: [PATCH] Add more cases to `test_rich_measure`. Rename `test_init_append_column` --- tests/test_table.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/test_table.py b/tests/test_table.py index 7ca37409..7c82c760 100644 --- a/tests/test_table.py +++ b/tests/test_table.py @@ -92,7 +92,7 @@ def test_not_renderable(): table.add_row(Foo()) -def test_append_column(): +def test_init_append_column(): header_names = ["header1", "header2", "header3"] test_columns = [ Column(_index=index, header=header) for index, header in enumerate(header_names) @@ -106,9 +106,21 @@ def test_append_column(): def test_rich_measure(): # Check __rich_measure__() for a negative width passed as an argument - assert Table().__rich_measure__(Console(), -1) == Measurement(0, 0) + assert Table("test_header", width=None).__rich_measure__( + Console(), -1 + ) == Measurement(0, 0) # Check __rich_measure__() for a negative Table.width attribute - assert Table(width=-1).__rich_measure__(Console(), 1) == Measurement(0, 0) + assert Table("test_header", width=-1).__rich_measure__( + Console(), 1 + ) == Measurement(0, 0) + # Check __rich_measure__() for a positive width passed as an argument + assert Table("test_header", width=None).__rich_measure__( + Console(), 10 + ) == Measurement(10, 10) + # Check __rich_measure__() for a positive Table.width attribute + assert Table("test_header", width=10).__rich_measure__( + Console(), -1 + ) == Measurement(10, 10) if __name__ == "__main__":