Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(package): NamedTemporaryFile Being Opened Twice #2567

Merged
merged 23 commits into from Jan 29, 2021
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ceeba56
Bumped aws-sam-translator to 1.27.0
CoshUS Sep 22, 2020
bb11702
Bumped SAM CLI Version to 1.3.0
CoshUS Sep 22, 2020
e627c6d
Updated Reproducible Requirements
Sep 22, 2020
385041e
Merge branch 'develop' of https://github.com/aws/aws-sam-cli into dev…
CoshUS Oct 28, 2020
d3da38f
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Nov 16, 2020
24923f8
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Dec 1, 2020
218e731
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Dec 1, 2020
af18a89
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Dec 3, 2020
105538a
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Dec 7, 2020
320c497
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Dec 11, 2020
862be0f
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Dec 15, 2020
31bed23
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Dec 17, 2020
ba1c1b4
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Jan 7, 2021
5a14c86
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Jan 25, 2021
847fc5b
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Jan 27, 2021
89ec2fb
Merge remote-tracking branch 'upstream/develop' into develop
CoshUS Jan 29, 2021
c781bc3
Added Close to Packaged File
CoshUS Jan 29, 2021
a4e3b1c
Removed Debug Prints
CoshUS Jan 29, 2021
85f262a
Removed Debug Vars
CoshUS Jan 29, 2021
3af5752
Removed Another Debug Print
CoshUS Jan 29, 2021
2a0bd53
Formatting
CoshUS Jan 29, 2021
ea9d847
Merge branch 'develop' into fix/package-named-temp-file
CoshUS Jan 29, 2021
bf660d0
Merge branch 'develop' into fix/package-named-temp-file
CoshUS Jan 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/integration/package/test_package_command_image.py
Expand Up @@ -131,6 +131,10 @@ def test_package_template_with_image_function_in_nested_application(self, templa
# when image function is not in main template, erc_repo_name does not show up in stdout
# here we download the nested application template file and verify its content
with tempfile.NamedTemporaryFile() as packaged_file, tempfile.TemporaryFile() as packaged_nested_file:
# https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile
# Closes the NamedTemporaryFile as on Windows NT or later, NamedTemporaryFile cannot be opened twice.
packaged_file.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use TemporaryFile() for package_file?

Copy link
Contributor Author

@CoshUS CoshUS Jan 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TemporaryFile does not guarantee the file is visible in the file system on Unix. We need to read the file later using packaged_file.name in order to validate the output.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a visible name for package_file in the file system, which is used for output_template_file in the command.

TemporaryFile() does not guarantee a visible name in the file system.
We don't need the file to actually exist though. Since the command will create the file again


command_list = self.get_command_list(
image_repository=self.ecr_repo_name,
template=template_path,
Expand Down