summaryrefslogtreecommitdiffstats
path: root/tests/tabular_output
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-18 17:45:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-18 17:45:04 +0000
commitbf6656b601d10f139d5b146eb65feca9f4f3fe91 (patch)
treefff61580a08934083aab3043d228c2f484f6f844 /tests/tabular_output
parentAdding upstream version 2.2.1. (diff)
downloadcli-helpers-bf6656b601d10f139d5b146eb65feca9f4f3fe91.tar.xz
cli-helpers-bf6656b601d10f139d5b146eb65feca9f4f3fe91.zip
Adding upstream version 2.3.0.upstream/2.3.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/tabular_output')
-rw-r--r--tests/tabular_output/test_output_formatter.py41
1 files changed, 39 insertions, 2 deletions
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
@@ -23,6 +23,41 @@ def test_tabular_output_formatter():
]
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(
+ """\
+------------+---------+
| text | numeric |
+------------+---------+
@@ -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"
+ )
)