From bde3b5a9868760190f1cbda3eb4e133d3db9409d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 18 Oct 2022 19:45:07 +0200 Subject: Merging upstream version 2.3.0. Signed-off-by: Daniel Baumann --- tests/tabular_output/test_output_formatter.py | 41 +++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'tests/tabular_output') diff --git a/tests/tabular_output/test_output_formatter.py b/tests/tabular_output/test_output_formatter.py index b307c1c..8e1fa92 100644 --- a/tests/tabular_output/test_output_formatter.py +++ b/tests/tabular_output/test_output_formatter.py @@ -21,6 +21,41 @@ def test_tabular_output_formatter(): ["hi", Decimal("1.1")], ["Pablo\rß\n", 0], ] + expected = dedent( + """\ + +-------+---------+ + | text | numeric | + +-------+---------+ + | abc | 1 | + | defg | 11.1 | + | hi | 1.1 | + | Pablo | 0 | + | ß | | + +-------+---------+""" + ) + + print(expected) + print( + "\n".join( + TabularOutputFormatter().format_output( + iter(data), headers, format_name="ascii" + ) + ) + ) + assert expected == "\n".join( + TabularOutputFormatter().format_output(iter(data), headers, format_name="ascii") + ) + + +def test_tabular_output_escaped(): + """Test the ascii_escaped output format.""" + headers = ["text", "numeric"] + data = [ + ["abc", Decimal(1)], + ["defg", Decimal("11.1")], + ["hi", Decimal("1.1")], + ["Pablo\rß\n", 0], + ] expected = dedent( """\ +------------+---------+ @@ -37,12 +72,14 @@ def test_tabular_output_formatter(): print( "\n".join( TabularOutputFormatter().format_output( - iter(data), headers, format_name="ascii" + iter(data), headers, format_name="ascii_escaped" ) ) ) assert expected == "\n".join( - TabularOutputFormatter().format_output(iter(data), headers, format_name="ascii") + TabularOutputFormatter().format_output( + iter(data), headers, format_name="ascii_escaped" + ) ) -- cgit v1.2.3