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

Fix tag value writer #517

Merged
merged 3 commits into from
Mar 10, 2023
Merged

Conversation

meretp
Copy link
Collaborator

@meretp meretp commented Mar 10, 2023

Due to the type conversion before entering the set_value method a None value for LicenseListVersion was written to the outptut file. The f-string calls the implemented str-conversion for the instance of Version, so we don't need to do this conversion explicitly.

To improve the test coverage here, I also added a test.

Copy link
Collaborator

@armintaenzertng armintaenzertng left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, I have just some stylistic remarks.

Comment on lines 37 to 40
m = mock_open()
with patch("{}.open".format(__name__), m, create=True):
with open("foo", "w") as h:
write_creation_info(creation_info, h)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get that they are throw-away variables, but can we give m and h slightly more descriptive names?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

m.assert_called_once_with("foo", "w")
handle = m()
handle.write.assert_has_calls(
expected_calls)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unnecessary line break

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

call("Created: 2022-03-10T00:00:00Z\n")])])
def test_creation_info_writer(creation_info, expected_calls):
m = mock_open()
with patch("{}.open".format(__name__), m, create=True):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use an f-string here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed, I just copied the code from test_package_writer.py. I would suggest to change the formatted string there when fixing #394 is fixed, okay?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer fixing it now so that next time it is not copied from there again ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@meretp meretp merged commit 08b447d into spdx:refactor-python-tools Mar 10, 2023
@meretp meretp deleted the fix-tag-value-writer branch March 10, 2023 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants