From 4949bea4e280247dea95f805c45d3ec00c9fdc89 Mon Sep 17 00:00:00 2001 From: Pearcekieser <5055971+Pearcekieser@users.noreply.github.com> Date: Thu, 19 Aug 2021 02:19:49 -0700 Subject: [PATCH] fix(cli): Python init template does not work in directory with '-' (#15939) fixes #15938 Pytest error after init sample-app on directory "aws-data-pipeline" ``` E File "C:\Users\<...>\aws-data-pipeline\tests\unit\test_aws_data_pipe E from aws-data-pipeline.aws_data_pipeline_stack import AwsDataPipelineStack E ^ E SyntaxError: invalid syntax ``` See https://github.com/aws/aws-cdk/issues/15938 for detials I was having trouble getting the aws-cdk build and tests running in my dev env. I think its some issues trying to build the code on windows. Do you have any recommendations on how to best add a test for this change? ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../tests/unit/test_%name.PythonModule%_stack.template.py | 2 +- .../tests/unit/test_%name.PythonModule%_stack.template.py | 2 +- packages/aws-cdk/test/integ/init/test-python.sh | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/lib/init-templates/v1/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py b/packages/aws-cdk/lib/init-templates/v1/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py index fab17d075ac44..182d07fe09855 100644 --- a/packages/aws-cdk/lib/init-templates/v1/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py +++ b/packages/aws-cdk/lib/init-templates/v1/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py @@ -2,7 +2,7 @@ import pytest from aws_cdk import core -from %name%.%name.PythonModule%_stack import %name.PascalCased%Stack +from %name.PythonModule%.%name.PythonModule%_stack import %name.PascalCased%Stack def get_template(): diff --git a/packages/aws-cdk/lib/init-templates/v2/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py b/packages/aws-cdk/lib/init-templates/v2/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py index 2b7e876b75742..b51a164ff8c5e 100644 --- a/packages/aws-cdk/lib/init-templates/v2/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py +++ b/packages/aws-cdk/lib/init-templates/v2/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py @@ -2,7 +2,7 @@ import pytest import aws_cdk_lib as core -from %name%.%name.PythonModule%_stack import %name.PascalCased%Stack +from %name.PythonModule%.%name.PythonModule%_stack import %name.PascalCased%Stack def get_template(): diff --git a/packages/aws-cdk/test/integ/init/test-python.sh b/packages/aws-cdk/test/integ/init/test-python.sh index 1f5163df5ae48..dd944e8369342 100755 --- a/packages/aws-cdk/test/integ/init/test-python.sh +++ b/packages/aws-cdk/test/integ/init/test-python.sh @@ -28,4 +28,5 @@ for template in $templates; do pip install -r requirements.txt cdk synth + pytest done