diff options
Diffstat (limited to 'tests/pyreverse')
27 files changed, 175 insertions, 183 deletions
diff --git a/tests/pyreverse/conftest.py b/tests/pyreverse/conftest.py index 02a19e613..9e1741f0a 100644 --- a/tests/pyreverse/conftest.py +++ b/tests/pyreverse/conftest.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt from __future__ import annotations @@ -29,9 +29,10 @@ def colorized_dot_config() -> PyreverseConfig: @pytest.fixture() -def vcg_config() -> PyreverseConfig: +def no_standalone_dot_config() -> PyreverseConfig: return PyreverseConfig( - output_format="vcg", + output_format="dot", + no_standalone=True, ) diff --git a/tests/pyreverse/data/classes_No_Name.dot b/tests/pyreverse/data/classes_No_Name.dot index 2e8830fa0..a33f65da3 100644 --- a/tests/pyreverse/data/classes_No_Name.dot +++ b/tests/pyreverse/data/classes_No_Name.dot @@ -11,7 +11,6 @@ charset="utf-8" "data.property_pattern.PropertyPatterns" [color="black", fontcolor="black", label=<{PropertyPatterns|prop1<br ALIGN="LEFT"/>prop2<br ALIGN="LEFT"/>|}>, shape="record", style="solid"]; "data.clientmodule_test.Specialization" [color="black", fontcolor="black", label=<{Specialization|TYPE : str<br ALIGN="LEFT"/>relation<br ALIGN="LEFT"/>relation2<br ALIGN="LEFT"/>top : str<br ALIGN="LEFT"/>|from_value(value: int)<br ALIGN="LEFT"/>increment_value(): None<br ALIGN="LEFT"/>transform_value(value: int): int<br ALIGN="LEFT"/>}>, shape="record", style="solid"]; "data.clientmodule_test.Specialization" -> "data.clientmodule_test.Ancestor" [arrowhead="empty", arrowtail="none"]; -"data.clientmodule_test.Ancestor" -> "data.suppliermodule_test.Interface" [arrowhead="empty", arrowtail="node", style="dashed"]; "data.suppliermodule_test.DoNothing" -> "data.clientmodule_test.Ancestor" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="cls_member", style="solid"]; "data.suppliermodule_test.DoNothing" -> "data.clientmodule_test.Specialization" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="relation", style="solid"]; "data.suppliermodule_test.DoNothing2" -> "data.clientmodule_test.Specialization" [arrowhead="odiamond", arrowtail="none", fontcolor="green", label="relation2", style="solid"]; diff --git a/tests/pyreverse/data/classes_No_Name.html b/tests/pyreverse/data/classes_No_Name.html index bed9a8d14..bf4c17d0d 100644 --- a/tests/pyreverse/data/classes_No_Name.html +++ b/tests/pyreverse/data/classes_No_Name.html @@ -44,7 +44,6 @@ transform_value(value: int) int } Specialization --|> Ancestor - Ancestor ..|> Interface DoNothing --* Ancestor : cls_member DoNothing --* Specialization : relation DoNothing2 --o Specialization : relation2 diff --git a/tests/pyreverse/data/classes_No_Name.mmd b/tests/pyreverse/data/classes_No_Name.mmd index 53cb4fc3c..9f38089de 100644 --- a/tests/pyreverse/data/classes_No_Name.mmd +++ b/tests/pyreverse/data/classes_No_Name.mmd @@ -39,7 +39,6 @@ classDiagram transform_value(value: int) int } Specialization --|> Ancestor - Ancestor ..|> Interface DoNothing --* Ancestor : cls_member DoNothing --* Specialization : relation DoNothing2 --o Specialization : relation2 diff --git a/tests/pyreverse/data/classes_No_Name.puml b/tests/pyreverse/data/classes_No_Name.puml index e4d06a00c..0b01169e4 100644 --- a/tests/pyreverse/data/classes_No_Name.puml +++ b/tests/pyreverse/data/classes_No_Name.puml @@ -40,7 +40,6 @@ class "Specialization" as data.clientmodule_test.Specialization { transform_value(value: int) -> int } data.clientmodule_test.Specialization --|> data.clientmodule_test.Ancestor -data.clientmodule_test.Ancestor ..|> data.suppliermodule_test.Interface data.suppliermodule_test.DoNothing --* data.clientmodule_test.Ancestor : cls_member data.suppliermodule_test.DoNothing --* data.clientmodule_test.Specialization : relation data.suppliermodule_test.DoNothing2 --o data.clientmodule_test.Specialization : relation2 diff --git a/tests/pyreverse/data/classes_colorized.dot b/tests/pyreverse/data/classes_colorized.dot index 49dc8a7e1..729b05828 100644 --- a/tests/pyreverse/data/classes_colorized.dot +++ b/tests/pyreverse/data/classes_colorized.dot @@ -1,17 +1,16 @@ digraph "classes_colorized" { rankdir=BT charset="utf-8" -"data.clientmodule_test.Ancestor" [color="aliceblue", fontcolor="black", label=<{Ancestor|attr : str<br ALIGN="LEFT"/>cls_member<br ALIGN="LEFT"/>|get_value()<br ALIGN="LEFT"/>set_value(value)<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; -"data.suppliermodule_test.CustomException" [color="aliceblue", fontcolor="red", label=<{CustomException|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"]; -"data.suppliermodule_test.DoNothing" [color="aliceblue", fontcolor="black", label=<{DoNothing|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"]; -"data.suppliermodule_test.DoNothing2" [color="aliceblue", fontcolor="black", label=<{DoNothing2|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"]; -"data.suppliermodule_test.DoSomething" [color="aliceblue", fontcolor="black", label=<{DoSomething|my_int : Optional[int]<br ALIGN="LEFT"/>my_int_2 : Optional[int]<br ALIGN="LEFT"/>my_string : str<br ALIGN="LEFT"/>|do_it(new_int: int): int<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; -"data.suppliermodule_test.Interface" [color="aliceblue", fontcolor="black", label=<{Interface|<br ALIGN="LEFT"/>|<I>get_value</I>()<br ALIGN="LEFT"/><I>set_value</I>(value)<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; -"data.nullable_pattern.NullablePatterns" [color="aliceblue", fontcolor="black", label=<{NullablePatterns|<br ALIGN="LEFT"/>|<I>return_nullable_1</I>(): int \| None<br ALIGN="LEFT"/><I>return_nullable_2</I>(): Optional[int]<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; -"data.property_pattern.PropertyPatterns" [color="aliceblue", fontcolor="black", label=<{PropertyPatterns|prop1<br ALIGN="LEFT"/>prop2<br ALIGN="LEFT"/>|}>, shape="record", style="filled"]; -"data.clientmodule_test.Specialization" [color="aliceblue", fontcolor="black", label=<{Specialization|TYPE : str<br ALIGN="LEFT"/>relation<br ALIGN="LEFT"/>relation2<br ALIGN="LEFT"/>top : str<br ALIGN="LEFT"/>|from_value(value: int)<br ALIGN="LEFT"/>increment_value(): None<br ALIGN="LEFT"/>transform_value(value: int): int<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; +"data.clientmodule_test.Ancestor" [color="#77AADD", fontcolor="black", label=<{Ancestor|attr : str<br ALIGN="LEFT"/>cls_member<br ALIGN="LEFT"/>|get_value()<br ALIGN="LEFT"/>set_value(value)<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; +"data.suppliermodule_test.CustomException" [color="#77AADD", fontcolor="red", label=<{CustomException|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"]; +"data.suppliermodule_test.DoNothing" [color="#77AADD", fontcolor="black", label=<{DoNothing|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"]; +"data.suppliermodule_test.DoNothing2" [color="#77AADD", fontcolor="black", label=<{DoNothing2|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"]; +"data.suppliermodule_test.DoSomething" [color="#77AADD", fontcolor="black", label=<{DoSomething|my_int : Optional[int]<br ALIGN="LEFT"/>my_int_2 : Optional[int]<br ALIGN="LEFT"/>my_string : str<br ALIGN="LEFT"/>|do_it(new_int: int): int<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; +"data.suppliermodule_test.Interface" [color="#77AADD", fontcolor="black", label=<{Interface|<br ALIGN="LEFT"/>|<I>get_value</I>()<br ALIGN="LEFT"/><I>set_value</I>(value)<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; +"data.nullable_pattern.NullablePatterns" [color="#77AADD", fontcolor="black", label=<{NullablePatterns|<br ALIGN="LEFT"/>|<I>return_nullable_1</I>(): int \| None<br ALIGN="LEFT"/><I>return_nullable_2</I>(): Optional[int]<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; +"data.property_pattern.PropertyPatterns" [color="#77AADD", fontcolor="black", label=<{PropertyPatterns|prop1<br ALIGN="LEFT"/>prop2<br ALIGN="LEFT"/>|}>, shape="record", style="filled"]; +"data.clientmodule_test.Specialization" [color="#77AADD", fontcolor="black", label=<{Specialization|TYPE : str<br ALIGN="LEFT"/>relation<br ALIGN="LEFT"/>relation2<br ALIGN="LEFT"/>top : str<br ALIGN="LEFT"/>|from_value(value: int)<br ALIGN="LEFT"/>increment_value(): None<br ALIGN="LEFT"/>transform_value(value: int): int<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; "data.clientmodule_test.Specialization" -> "data.clientmodule_test.Ancestor" [arrowhead="empty", arrowtail="none"]; -"data.clientmodule_test.Ancestor" -> "data.suppliermodule_test.Interface" [arrowhead="empty", arrowtail="node", style="dashed"]; "data.suppliermodule_test.DoNothing" -> "data.clientmodule_test.Ancestor" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="cls_member", style="solid"]; "data.suppliermodule_test.DoNothing" -> "data.clientmodule_test.Specialization" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="relation", style="solid"]; "data.suppliermodule_test.DoNothing2" -> "data.clientmodule_test.Specialization" [arrowhead="odiamond", arrowtail="none", fontcolor="green", label="relation2", style="solid"]; diff --git a/tests/pyreverse/data/classes_colorized.puml b/tests/pyreverse/data/classes_colorized.puml index 9c046afa0..ef97398bc 100644 --- a/tests/pyreverse/data/classes_colorized.puml +++ b/tests/pyreverse/data/classes_colorized.puml @@ -1,36 +1,36 @@ @startuml classes_colorized set namespaceSeparator none -class "Ancestor" as data.clientmodule_test.Ancestor #aliceblue { +class "Ancestor" as data.clientmodule_test.Ancestor #77AADD { attr : str cls_member get_value() set_value(value) } -class "<color:red>CustomException</color>" as data.suppliermodule_test.CustomException #aliceblue { +class "<color:red>CustomException</color>" as data.suppliermodule_test.CustomException #77AADD { } -class "DoNothing" as data.suppliermodule_test.DoNothing #aliceblue { +class "DoNothing" as data.suppliermodule_test.DoNothing #77AADD { } -class "DoNothing2" as data.suppliermodule_test.DoNothing2 #aliceblue { +class "DoNothing2" as data.suppliermodule_test.DoNothing2 #77AADD { } -class "DoSomething" as data.suppliermodule_test.DoSomething #aliceblue { +class "DoSomething" as data.suppliermodule_test.DoSomething #77AADD { my_int : Optional[int] my_int_2 : Optional[int] my_string : str do_it(new_int: int) -> int } -class "Interface" as data.suppliermodule_test.Interface #aliceblue { +class "Interface" as data.suppliermodule_test.Interface #77AADD { {abstract}get_value() {abstract}set_value(value) } -class "NullablePatterns" as data.nullable_pattern.NullablePatterns #aliceblue { +class "NullablePatterns" as data.nullable_pattern.NullablePatterns #77AADD { {abstract}return_nullable_1() -> int | None {abstract}return_nullable_2() -> Optional[int] } -class "PropertyPatterns" as data.property_pattern.PropertyPatterns #aliceblue { +class "PropertyPatterns" as data.property_pattern.PropertyPatterns #77AADD { prop1 prop2 } -class "Specialization" as data.clientmodule_test.Specialization #aliceblue { +class "Specialization" as data.clientmodule_test.Specialization #77AADD { TYPE : str relation relation2 @@ -40,7 +40,6 @@ class "Specialization" as data.clientmodule_test.Specialization #aliceblue { transform_value(value: int) -> int } data.clientmodule_test.Specialization --|> data.clientmodule_test.Ancestor -data.clientmodule_test.Ancestor ..|> data.suppliermodule_test.Interface data.suppliermodule_test.DoNothing --* data.clientmodule_test.Ancestor : cls_member data.suppliermodule_test.DoNothing --* data.clientmodule_test.Specialization : relation data.suppliermodule_test.DoNothing2 --o data.clientmodule_test.Specialization : relation2 diff --git a/tests/pyreverse/data/classes_no_standalone.dot b/tests/pyreverse/data/classes_no_standalone.dot new file mode 100644 index 000000000..7cffc0a38 --- /dev/null +++ b/tests/pyreverse/data/classes_no_standalone.dot @@ -0,0 +1,12 @@ +digraph "classes_no_standalone" { +rankdir=BT +charset="utf-8" +"data.clientmodule_test.Ancestor" [color="black", fontcolor="black", label=<{Ancestor|attr : str<br ALIGN="LEFT"/>cls_member<br ALIGN="LEFT"/>|get_value()<br ALIGN="LEFT"/>set_value(value)<br ALIGN="LEFT"/>}>, shape="record", style="solid"]; +"data.suppliermodule_test.DoNothing" [color="black", fontcolor="black", label=<{DoNothing|<br ALIGN="LEFT"/>|}>, shape="record", style="solid"]; +"data.suppliermodule_test.DoNothing2" [color="black", fontcolor="black", label=<{DoNothing2|<br ALIGN="LEFT"/>|}>, shape="record", style="solid"]; +"data.clientmodule_test.Specialization" [color="black", fontcolor="black", label=<{Specialization|TYPE : str<br ALIGN="LEFT"/>relation<br ALIGN="LEFT"/>relation2<br ALIGN="LEFT"/>top : str<br ALIGN="LEFT"/>|from_value(value: int)<br ALIGN="LEFT"/>increment_value(): None<br ALIGN="LEFT"/>transform_value(value: int): int<br ALIGN="LEFT"/>}>, shape="record", style="solid"]; +"data.clientmodule_test.Specialization" -> "data.clientmodule_test.Ancestor" [arrowhead="empty", arrowtail="none"]; +"data.suppliermodule_test.DoNothing" -> "data.clientmodule_test.Ancestor" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="cls_member", style="solid"]; +"data.suppliermodule_test.DoNothing" -> "data.clientmodule_test.Specialization" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="relation", style="solid"]; +"data.suppliermodule_test.DoNothing2" -> "data.clientmodule_test.Specialization" [arrowhead="odiamond", arrowtail="none", fontcolor="green", label="relation2", style="solid"]; +} diff --git a/tests/pyreverse/data/packages_colorized.dot b/tests/pyreverse/data/packages_colorized.dot index eacc932b1..202c9a4e5 100644 --- a/tests/pyreverse/data/packages_colorized.dot +++ b/tests/pyreverse/data/packages_colorized.dot @@ -1,10 +1,10 @@ digraph "packages_colorized" { rankdir=BT charset="utf-8" -"data" [color="aliceblue", label=<data>, shape="box", style="filled"]; -"data.clientmodule_test" [color="aliceblue", label=<data.clientmodule_test>, shape="box", style="filled"]; -"data.nullable_pattern" [color="aliceblue", label=<data.nullable_pattern>, shape="box", style="filled"]; -"data.property_pattern" [color="aliceblue", label=<data.property_pattern>, shape="box", style="filled"]; -"data.suppliermodule_test" [color="aliceblue", label=<data.suppliermodule_test>, shape="box", style="filled"]; +"data" [color="#77AADD", label=<data>, shape="box", style="filled"]; +"data.clientmodule_test" [color="#77AADD", label=<data.clientmodule_test>, shape="box", style="filled"]; +"data.nullable_pattern" [color="#77AADD", label=<data.nullable_pattern>, shape="box", style="filled"]; +"data.property_pattern" [color="#77AADD", label=<data.property_pattern>, shape="box", style="filled"]; +"data.suppliermodule_test" [color="#77AADD", label=<data.suppliermodule_test>, shape="box", style="filled"]; "data.clientmodule_test" -> "data.suppliermodule_test" [arrowhead="open", arrowtail="none"]; } diff --git a/tests/pyreverse/data/packages_colorized.puml b/tests/pyreverse/data/packages_colorized.puml index 1066a9448..639c0654f 100644 --- a/tests/pyreverse/data/packages_colorized.puml +++ b/tests/pyreverse/data/packages_colorized.puml @@ -1,19 +1,14 @@ @startuml packages_colorized set namespaceSeparator none -package "data" as data #aliceblue { - +package "data" as data #77AADD { } -package "data.clientmodule_test" as data.clientmodule_test #aliceblue { - +package "data.clientmodule_test" as data.clientmodule_test #77AADD { } -package "data.nullable_pattern" as data.nullable_pattern #aliceblue { - +package "data.nullable_pattern" as data.nullable_pattern #77AADD { } -package "data.property_pattern" as data.property_pattern #aliceblue { - +package "data.property_pattern" as data.property_pattern #77AADD { } -package "data.suppliermodule_test" as data.suppliermodule_test #aliceblue { - +package "data.suppliermodule_test" as data.suppliermodule_test #77AADD { } data.clientmodule_test --> data.suppliermodule_test @enduml diff --git a/tests/pyreverse/data/packages_no_standalone.dot b/tests/pyreverse/data/packages_no_standalone.dot new file mode 100644 index 000000000..008c9c5d0 --- /dev/null +++ b/tests/pyreverse/data/packages_no_standalone.dot @@ -0,0 +1,7 @@ +digraph "packages_no_standalone" { +rankdir=BT +charset="utf-8" +"data.clientmodule_test" [color="black", label=<data.clientmodule_test>, shape="box", style="solid"]; +"data.suppliermodule_test" [color="black", label=<data.suppliermodule_test>, shape="box", style="solid"]; +"data.clientmodule_test" -> "data.suppliermodule_test" [arrowhead="open", arrowtail="none"]; +} diff --git a/tests/pyreverse/functional/class_diagrams/colorized_output/colorized.puml b/tests/pyreverse/functional/class_diagrams/colorized_output/colorized.puml index a5ccf11f7..10575159d 100644 --- a/tests/pyreverse/functional/class_diagrams/colorized_output/colorized.puml +++ b/tests/pyreverse/functional/class_diagrams/colorized_output/colorized.puml @@ -1,18 +1,18 @@ @startuml classes set namespaceSeparator none -class "CheckerCollector" as colorized.CheckerCollector #aliceblue { +class "CheckerCollector" as colorized.CheckerCollector #77AADD { checker1 checker2 checker3 } -class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #antiquewhite { +class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #99DDFF { msgs : dict name : str leave_module(_: nodes.Module) -> None process_tokens(tokens: list[TokenInfo]) -> None visit_if(node: nodes.If) -> None } -class "ExceptionsChecker" as pylint.checkers.exceptions.ExceptionsChecker #aquamarine { +class "ExceptionsChecker" as pylint.checkers.exceptions.ExceptionsChecker #44BB99 { msgs : dict name : str options : tuple @@ -22,7 +22,7 @@ class "ExceptionsChecker" as pylint.checkers.exceptions.ExceptionsChecker #aquam visit_raise(node: nodes.Raise) -> None visit_tryexcept(node: nodes.TryExcept) -> None } -class "StdlibChecker" as pylint.checkers.stdlib.StdlibChecker #aquamarine { +class "StdlibChecker" as pylint.checkers.stdlib.StdlibChecker #44BB99 { msgs : dict[str, MessageDefinitionTuple] name : str deprecated_arguments(method: str) -> tuple[tuple[int | None, str], ...] diff --git a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.dot b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.dot new file mode 100644 index 000000000..7263cf8f5 --- /dev/null +++ b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.dot @@ -0,0 +1,11 @@ +digraph "classes" { +rankdir=BT +charset="utf-8" +"custom_colors.CheckerCollector" [color="red", fontcolor="black", label=<{CheckerCollector|checker1<br ALIGN="LEFT"/>checker2<br ALIGN="LEFT"/>checker3<br ALIGN="LEFT"/>|}>, shape="record", style="filled"]; +"pylint.extensions.check_elif.ElseifUsedChecker" [color="#44BB88", fontcolor="black", label=<{ElseifUsedChecker|msgs : dict<br ALIGN="LEFT"/>name : str<br ALIGN="LEFT"/>|leave_module(_: nodes.Module): None<br ALIGN="LEFT"/>process_tokens(tokens: list[TokenInfo]): None<br ALIGN="LEFT"/>visit_if(node: nodes.If): None<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; +"pylint.checkers.exceptions.ExceptionsChecker" [color="yellow", fontcolor="black", label=<{ExceptionsChecker|msgs : dict<br ALIGN="LEFT"/>name : str<br ALIGN="LEFT"/>options : tuple<br ALIGN="LEFT"/>|open(): None<br ALIGN="LEFT"/>visit_binop(node: nodes.BinOp): None<br ALIGN="LEFT"/>visit_compare(node: nodes.Compare): None<br ALIGN="LEFT"/>visit_raise(node: nodes.Raise): None<br ALIGN="LEFT"/>visit_tryexcept(node: nodes.TryExcept): None<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; +"pylint.checkers.stdlib.StdlibChecker" [color="yellow", fontcolor="black", label=<{StdlibChecker|msgs : dict[str, MessageDefinitionTuple]<br ALIGN="LEFT"/>name : str<br ALIGN="LEFT"/>|deprecated_arguments(method: str): tuple[tuple[int \| None, str], ...]<br ALIGN="LEFT"/>deprecated_classes(module: str): Iterable[str]<br ALIGN="LEFT"/>deprecated_decorators(): Iterable[str]<br ALIGN="LEFT"/>deprecated_methods(): set[str]<br ALIGN="LEFT"/>visit_boolop(node: nodes.BoolOp): None<br ALIGN="LEFT"/>visit_call(node: nodes.Call): None<br ALIGN="LEFT"/>visit_functiondef(node: nodes.FunctionDef): None<br ALIGN="LEFT"/>visit_if(node: nodes.If): None<br ALIGN="LEFT"/>visit_ifexp(node: nodes.IfExp): None<br ALIGN="LEFT"/>visit_unaryop(node: nodes.UnaryOp): None<br ALIGN="LEFT"/>}>, shape="record", style="filled"]; +"pylint.checkers.exceptions.ExceptionsChecker" -> "custom_colors.CheckerCollector" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="checker1", style="solid"]; +"pylint.checkers.stdlib.StdlibChecker" -> "custom_colors.CheckerCollector" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="checker3", style="solid"]; +"pylint.extensions.check_elif.ElseifUsedChecker" -> "custom_colors.CheckerCollector" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="checker2", style="solid"]; +} diff --git a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml index 34dc814ff..f2cea9f63 100644 --- a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml +++ b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml @@ -5,7 +5,7 @@ class "CheckerCollector" as custom_colors.CheckerCollector #red { checker2 checker3 } -class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #green { +class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #44BB88 { msgs : dict name : str leave_module(_: nodes.Module) -> None diff --git a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc index ea30ad4a4..08f68bbb3 100644 --- a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc +++ b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc @@ -1,3 +1,3 @@ [testoptions] -output_formats=puml -command_line_args=-S --colorized --max-color-depth=2 --color-palette=red,green,yellow +output_formats=puml,dot +command_line_args=-S --colorized --max-color-depth=2 --color-palette=red,#44BB88,yellow diff --git a/tests/pyreverse/functional/class_diagrams/inheritance/no_standalone.mmd b/tests/pyreverse/functional/class_diagrams/inheritance/no_standalone.mmd new file mode 100644 index 000000000..646d8220d --- /dev/null +++ b/tests/pyreverse/functional/class_diagrams/inheritance/no_standalone.mmd @@ -0,0 +1,6 @@ +classDiagram + class A { + } + class B { + } + B --|> A diff --git a/tests/pyreverse/functional/class_diagrams/inheritance/no_standalone.py b/tests/pyreverse/functional/class_diagrams/inheritance/no_standalone.py new file mode 100644 index 000000000..3d881d4c0 --- /dev/null +++ b/tests/pyreverse/functional/class_diagrams/inheritance/no_standalone.py @@ -0,0 +1,5 @@ +class A: pass + +class B(A): pass + +class C: pass diff --git a/tests/pyreverse/functional/class_diagrams/inheritance/no_standalone.rc b/tests/pyreverse/functional/class_diagrams/inheritance/no_standalone.rc new file mode 100644 index 000000000..c17e41cfb --- /dev/null +++ b/tests/pyreverse/functional/class_diagrams/inheritance/no_standalone.rc @@ -0,0 +1,2 @@ +[testoptions] +command_line_args=--no-standalone diff --git a/tests/pyreverse/test_diadefs.py b/tests/pyreverse/test_diadefs.py index 96cafc2ef..cdcdea7c5 100644 --- a/tests/pyreverse/test_diadefs.py +++ b/tests/pyreverse/test_diadefs.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """Unit test for the extensions.diadefslib modules.""" @@ -13,7 +13,7 @@ from collections.abc import Iterator from pathlib import Path import pytest -from astroid import nodes +from astroid import extract_node, nodes from pylint.pyreverse.diadefslib import ( ClassDiadefGenerator, @@ -97,19 +97,61 @@ def test_default_values() -> None: # TODO : should test difference between default values for package or class diagrams +class TestShowOptions: + def test_show_stdlib(self) -> None: + example = extract_node( + ''' + import collections + + class CustomDict(collections.OrderedDict): + """docstring""" + ''' + ) + + config = PyreverseConfig() + dd_gen = DiaDefGenerator(Linker(PROJECT), DiadefsHandler(config)) + + # Default behavior + assert not list(dd_gen.get_ancestors(example, 1)) + + # Show standard library enabled + config.show_stdlib = True + ancestors = list(dd_gen.get_ancestors(example, 1)) + assert len(ancestors) == 1 + assert ancestors[0].name == "OrderedDict" + + def test_show_builtin(self) -> None: + example = extract_node( + ''' + class CustomError(Exception): + """docstring""" + ''' + ) + + config = PyreverseConfig() + dd_gen = DiaDefGenerator(Linker(PROJECT), DiadefsHandler(config)) + + # Default behavior + assert not list(dd_gen.get_ancestors(example, 1)) + + # Show builtin enabled + config.show_builtin = True + ancestors = list(dd_gen.get_ancestors(example, 1)) + assert len(ancestors) == 1 + assert ancestors[0].name == "Exception" + + class TestDefaultDiadefGenerator: _should_rels = [ ("aggregation", "DoNothing2", "Specialization"), ("association", "DoNothing", "Ancestor"), ("association", "DoNothing", "Specialization"), - ("implements", "Ancestor", "Interface"), ("specialization", "Specialization", "Ancestor"), ] def test_extract_relations(self, HANDLER: DiadefsHandler, PROJECT: Project) -> None: """Test extract_relations between classes.""" - with pytest.warns(DeprecationWarning): - cd = DefaultDiadefGenerator(Linker(PROJECT), HANDLER).visit(PROJECT)[1] + cd = DefaultDiadefGenerator(Linker(PROJECT), HANDLER).visit(PROJECT)[1] cd.extract_relationships() relations = _process_relations(cd.relationships) assert relations == self._should_rels diff --git a/tests/pyreverse/test_diagrams.py b/tests/pyreverse/test_diagrams.py index 863bcecc9..761aa0692 100644 --- a/tests/pyreverse/test_diagrams.py +++ b/tests/pyreverse/test_diagrams.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """Unit test for the diagrams modules.""" diff --git a/tests/pyreverse/test_inspector.py b/tests/pyreverse/test_inspector.py index 54fff0896..d28d99584 100644 --- a/tests/pyreverse/test_inspector.py +++ b/tests/pyreverse/test_inspector.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """For the visitors.diadefs module.""" @@ -15,7 +15,6 @@ from pathlib import Path import astroid import pytest -from astroid import nodes from pylint.pyreverse import inspector from pylint.pyreverse.inspector import Project @@ -37,20 +36,6 @@ def project(get_project: GetProjectCallable) -> Generator[Project, None, None]: yield project -def test_class_implements(project: Project) -> None: - klass = project.get_module("data.clientmodule_test")["Ancestor"] - assert hasattr(klass, "implements") - assert len(klass.implements) == 1 - assert isinstance(klass.implements[0], nodes.ClassDef) - assert klass.implements[0].name == "Interface" - - -def test_class_implements_specialization(project: Project) -> None: - klass = project.get_module("data.clientmodule_test")["Specialization"] - assert hasattr(klass, "implements") - assert len(klass.implements) == 0 - - def test_locals_assignment_resolution(project: Project) -> None: klass = project.get_module("data.clientmodule_test")["Specialization"] assert hasattr(klass, "locals_type") @@ -78,54 +63,6 @@ def test_instance_attrs_resolution(project: Project) -> None: assert type_dict["_id"][0] is astroid.Uninferable -def test_concat_interfaces() -> None: - cls = astroid.extract_node( - ''' - class IMachin: pass - - class Correct2: - """docstring""" - __implements__ = (IMachin,) - - class BadArgument: - """docstring""" - __implements__ = (IMachin,) - - class InterfaceCanNowBeFound: #@ - """docstring""" - __implements__ = BadArgument.__implements__ + Correct2.__implements__ - ''' - ) - interfaces = inspector.interfaces(cls) - assert [i.name for i in interfaces] == ["IMachin"] - - -def test_interfaces() -> None: - module = astroid.parse( - """ - class Interface(object): pass - class MyIFace(Interface): pass - class AnotherIFace(Interface): pass - class Concrete0(object): - __implements__ = MyIFace - class Concrete1: - __implements__ = (MyIFace, AnotherIFace) - class Concrete2: - __implements__ = (MyIFace, AnotherIFace) - class Concrete23(Concrete1): pass - """ - ) - - for klass, interfaces in ( - ("Concrete0", ["MyIFace"]), - ("Concrete1", ["MyIFace", "AnotherIFace"]), - ("Concrete2", ["MyIFace", "AnotherIFace"]), - ("Concrete23", []), - ): - klass = module[klass] - assert [i.name for i in inspector.interfaces(klass)] == interfaces - - def test_from_directory(project: Project) -> None: expected = os.path.join("tests", "data", "__init__.py") assert project.name == "data" @@ -141,18 +78,3 @@ def test_project_node(project: Project) -> None: "data.suppliermodule_test", ] assert sorted(project.keys()) == expected - - -def test_interface_deprecation(project: Project) -> None: - linker = inspector.Linker(project) - cls = astroid.extract_node( - ''' - class IMachin: pass - - class Concrete: #@ - """docstring""" - __implements__ = (IMachin,) - ''' - ) - with pytest.warns(DeprecationWarning): - linker.visit_classdef(cls) diff --git a/tests/pyreverse/test_main.py b/tests/pyreverse/test_main.py index 86401e05b..350550585 100644 --- a/tests/pyreverse/test_main.py +++ b/tests/pyreverse/test_main.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """Unittest for the main module.""" @@ -138,6 +138,7 @@ def test_graphviz_unsupported_image_format(capsys: CaptureFixture) -> None: ("show_associated", None), ("all_associated", None), ("show_builtin", 0), + ("show_stdlib", 0), ("module_names", None), ("output_format", "dot"), ("colorized", 0), diff --git a/tests/pyreverse/test_printer.py b/tests/pyreverse/test_printer.py index 4248e8bae..67b4186b8 100644 --- a/tests/pyreverse/test_printer.py +++ b/tests/pyreverse/test_printer.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt from __future__ import annotations @@ -10,7 +10,6 @@ from astroid import nodes from pylint.pyreverse.dot_printer import DotPrinter from pylint.pyreverse.plantuml_printer import PlantUmlPrinter from pylint.pyreverse.printer import Layout, NodeType, Printer -from pylint.pyreverse.vcg_printer import VCGPrinter @pytest.mark.parametrize( @@ -20,10 +19,6 @@ from pylint.pyreverse.vcg_printer import VCGPrinter (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), (Layout.TOP_TO_BOTTOM, PlantUmlPrinter, "top to bottom direction", -1), (Layout.LEFT_TO_RIGHT, PlantUmlPrinter, "left to right direction", -1), ], @@ -45,8 +40,15 @@ def test_unsupported_layout(layout: Layout, printer_class: type[Printer]) -> Non def test_method_arguments_none() -> None: - func = nodes.FunctionDef() - args = nodes.Arguments() + func = nodes.FunctionDef( + name="func", + lineno=1, + col_offset=0, + end_lineno=None, + end_col_offset=None, + parent=None, + ) + args = nodes.Arguments(vararg=None, kwarg=None, parent=func) args.args = None func.postinit(args, body=None) parsed_args = Printer._get_method_arguments(func) diff --git a/tests/pyreverse/test_printer_factory.py b/tests/pyreverse/test_printer_factory.py index 76406f0a8..23055be28 100644 --- a/tests/pyreverse/test_printer_factory.py +++ b/tests/pyreverse/test_printer_factory.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """Unit tests for pylint.pyreverse.printer_factory.""" @@ -12,13 +12,11 @@ from pylint.pyreverse import printer_factory from pylint.pyreverse.dot_printer import DotPrinter from pylint.pyreverse.plantuml_printer import PlantUmlPrinter from pylint.pyreverse.printer import Printer -from pylint.pyreverse.vcg_printer import VCGPrinter @pytest.mark.parametrize( "filetype, expected_printer_class", [ - ("vcg", VCGPrinter), ("dot", DotPrinter), ("puml", PlantUmlPrinter), ("plantuml", PlantUmlPrinter), diff --git a/tests/pyreverse/test_pyreverse_functional.py b/tests/pyreverse/test_pyreverse_functional.py index aab500b81..715ad3dad 100644 --- a/tests/pyreverse/test_pyreverse_functional.py +++ b/tests/pyreverse/test_pyreverse_functional.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt import os from pathlib import Path diff --git a/tests/pyreverse/test_utils.py b/tests/pyreverse/test_utils.py index d64bf4fa7..ef843fd29 100644 --- a/tests/pyreverse/test_utils.py +++ b/tests/pyreverse/test_utils.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """Tests for pylint.pyreverse.utils.""" diff --git a/tests/pyreverse/test_writer.py b/tests/pyreverse/test_writer.py index 0bf92d918..ed0f5b31e 100644 --- a/tests/pyreverse/test_writer.py +++ b/tests/pyreverse/test_writer.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """Unit test for ``DiagramWriter``.""" @@ -10,9 +10,11 @@ import codecs import os from collections.abc import Iterator from difflib import unified_diff +from pathlib import Path from unittest.mock import Mock import pytest +from pytest import MonkeyPatch from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler from pylint.pyreverse.inspector import Linker, Project @@ -32,19 +34,21 @@ _DEFAULTS = { "all_associated": None, "mode": "PUB_ONLY", "show_builtin": False, + "show_stdlib": False, "only_classnames": False, "output_directory": "", + "no_standalone": False, } TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "..", "data") DOT_FILES = ["packages_No_Name.dot", "classes_No_Name.dot"] COLORIZED_DOT_FILES = ["packages_colorized.dot", "classes_colorized.dot"] -VCG_FILES = ["packages_No_Name.vcg", "classes_No_Name.vcg"] PUML_FILES = ["packages_No_Name.puml", "classes_No_Name.puml"] COLORIZED_PUML_FILES = ["packages_colorized.puml", "classes_colorized.puml"] MMD_FILES = ["packages_No_Name.mmd", "classes_No_Name.mmd"] HTML_FILES = ["packages_No_Name.html", "classes_No_Name.html"] +NO_STANDALONE_FILES = ["classes_no_standalone.dot", "packages_no_standalone.dot"] class Config: @@ -69,6 +73,11 @@ def _file_lines(path: str) -> list[str]: return [line for line in lines if line] +@pytest.fixture(autouse=True) +def change_to_temp_dir(monkeypatch: MonkeyPatch, tmp_path: Path) -> None: + monkeypatch.chdir(tmp_path) + + @pytest.fixture() def setup_dot( default_config: PyreverseConfig, get_project: GetProjectCallable @@ -88,12 +97,12 @@ def setup_colorized_dot( @pytest.fixture() -def setup_vcg( - vcg_config: PyreverseConfig, get_project: GetProjectCallable +def setup_no_standalone_dot( + no_standalone_dot_config: PyreverseConfig, get_project: GetProjectCallable ) -> Iterator[None]: - writer = DiagramWriter(vcg_config) - project = get_project(TEST_DATA_DIR) - yield from _setup(project, vcg_config, writer) + writer = DiagramWriter(no_standalone_dot_config) + project = get_project(TEST_DATA_DIR, name="no_standalone") + yield from _setup(project, no_standalone_dot_config, writer) @pytest.fixture() @@ -144,19 +153,6 @@ def _setup( diagram.extract_relationships() writer.write(dd) yield - for fname in ( - DOT_FILES - + COLORIZED_DOT_FILES - + VCG_FILES - + PUML_FILES - + COLORIZED_PUML_FILES - + MMD_FILES - + HTML_FILES - ): - try: - os.remove(fname) - except FileNotFoundError: - continue @pytest.mark.usefixtures("setup_dot") @@ -171,9 +167,9 @@ def test_colorized_dot_files(generated_file: str) -> None: _assert_files_are_equal(generated_file) -@pytest.mark.usefixtures("setup_vcg") -@pytest.mark.parametrize("generated_file", VCG_FILES) -def test_vcg_files(generated_file: str) -> None: +@pytest.mark.usefixtures("setup_no_standalone_dot") +@pytest.mark.parametrize("generated_file", NO_STANDALONE_FILES) +def test_no_standalone_dot_files(generated_file: str) -> None: _assert_files_are_equal(generated_file) @@ -238,5 +234,3 @@ def test_package_name_with_slash(default_config: PyreverseConfig) -> None: writer.write([obj]) assert os.path.exists("test_package_name_with_slash_.dot") - # remove the generated file - os.remove("test_package_name_with_slash_.dot") |