diff --git a/test/unit/module/template/test_template.py b/test/unit/module/template/test_template.py index 2692152b3f..2ad5784634 100644 --- a/test/unit/module/template/test_template.py +++ b/test/unit/module/template/test_template.py @@ -5,6 +5,7 @@ import json import os +import sys from test.testlib.testcase import BaseTestCase from unittest.mock import patch @@ -40,7 +41,31 @@ def test_build_graph(self): dot = "test/fixtures/templates/good/generic.yaml.dot" # ruff: noqa: E501 - expected_content = """digraph "template" { + if sys.version_info >= (3, 9): + expected_content = """digraph "template" { +MyModule [label="MyModule\\n", color=black, shape=ellipse, type=Resource]; +RootRole [label="RootRole\\n", color=black, shape=ellipse, type=Resource]; +RolePolicies [label="RolePolicies\\n", color=black, shape=ellipse, type=Resource]; +RootInstanceProfile [label="RootInstanceProfile\\n", color=black, shape=ellipse, type=Resource]; +MyEC2Instance [label="MyEC2Instance\\n", color=black, shape=ellipse, type=Resource]; +mySnsTopic [label="mySnsTopic\\n", color=black, shape=ellipse, type=Resource]; +MyEC2Instance1 [label="MyEC2Instance1\\n", color=black, shape=ellipse, type=Resource]; +ElasticIP [label="ElasticIP\\n", color=black, shape=ellipse, type=Resource]; +ElasticLoadBalancer [label="ElasticLoadBalancer\\n", color=black, shape=ellipse, type=Resource]; +IamPipeline [label="IamPipeline\\n", color=black, shape=ellipse, type=Resource]; +CustomResource [label="CustomResource\\n", color=black, shape=ellipse, type=Resource]; +WaitCondition [label="WaitCondition\\n", color=black, shape=ellipse, type=Resource]; +LambdaFunction [label="LambdaFunction\\n", color=black, shape=ellipse, type=Resource]; +RolePolicies -> RootRole [key=0, source_paths="['Properties', 'Roles', 0]", label=Ref, color=black]; +RootInstanceProfile -> RootRole [key=0, source_paths="['Properties', 'Roles', 0]", label=Ref, color=black]; +MyEC2Instance -> RootInstanceProfile [key=0, source_paths="['Properties', 'IamInstanceProfile']", label=Ref, color=black]; +ElasticLoadBalancer -> MyEC2Instance [key=0, source_paths="['Properties', 'Instances', 0]", label=Ref, color=black]; +} +""".split( + "\n" + ) + else: + expected_content = """digraph "template" { MyModule [color=black, label="MyModule\\n", shape=ellipse, type=Resource]; RootRole [color=black, label="RootRole\\n", shape=ellipse, type=Resource]; RolePolicies [color=black, label="RolePolicies\\n", shape=ellipse, type=Resource]; @@ -60,8 +85,8 @@ def test_build_graph(self): ElasticLoadBalancer -> MyEC2Instance [color=black, key=0, label=Ref, source_paths="['Properties', 'Instances', 0]"]; } """.split( - "\n" - ) + "\n" + ) assert os.path.exists(dot) with open(dot, "r") as file: