summaryrefslogtreecommitdiff
path: root/tests/pyreverse/test_printer.py
diff options
context:
space:
mode:
authorDudeNr33 <3929834+DudeNr33@users.noreply.github.com>2021-08-08 15:53:44 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-08-09 20:00:57 +0200
commit5644fc137f52e12c194671fd045bfa3a80bc062b (patch)
tree7928e29d3a9eb3adb5a318c93d1cae0aed18ed48 /tests/pyreverse/test_printer.py
parent57300194ca9281e2477f1d6ff02c115188986991 (diff)
downloadpylint-git-5644fc137f52e12c194671fd045bfa3a80bc062b.tar.gz
Add tests for ``Printer`` classes which are not covered yet implicitly through ``test_writer``
Diffstat (limited to 'tests/pyreverse/test_printer.py')
-rw-r--r--tests/pyreverse/test_printer.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/pyreverse/test_printer.py b/tests/pyreverse/test_printer.py
new file mode 100644
index 000000000..d67107dbd
--- /dev/null
+++ b/tests/pyreverse/test_printer.py
@@ -0,0 +1,32 @@
+# Copyright (c) 2021 Andreas Finkler <andi.finkler@gmail.com>
+
+# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+# For details: https://github.com/PyCQA/pylint/blob/master/LICENSE
+
+from typing import Type
+
+import pytest
+
+from pylint.pyreverse.dot_printer import DotPrinter
+from pylint.pyreverse.printer import Layout, Printer
+from pylint.pyreverse.vcg_printer import VCGPrinter
+
+
+@pytest.mark.parametrize(
+ "layout, printer_class, expected_content, line_index",
+ [
+ (Layout.TOP_TO_BOTTOM, DotPrinter, "rankdir=TB", -2),
+ (Layout.BOTTOM_TO_TOP, DotPrinter, "rankdir=BT", -2),
+ (Layout.LEFT_TO_RIGHT, DotPrinter, "rankdir=LR", -2),
+ (Layout.RIGHT_TO_LEFT, DotPrinter, "rankdir=RL", -2),
+ (Layout.TOP_TO_BOTTOM, VCGPrinter, "orientation:top_to_bottom", -1),
+ (Layout.BOTTOM_TO_TOP, VCGPrinter, "orientation:bottom_to_top", -1),
+ (Layout.LEFT_TO_RIGHT, VCGPrinter, "orientation:left_to_right", -1),
+ (Layout.RIGHT_TO_LEFT, VCGPrinter, "orientation:right_to_left", -1),
+ ],
+)
+def test_explicit_layout(
+ layout: Layout, printer_class: Type[Printer], expected_content: str, line_index: int
+) -> None:
+ printer = printer_class(title="unittest", layout=layout)
+ assert printer.lines[line_index].strip() == expected_content