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

spdx3: element_writer: switch from tab characters to two spaces #785

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx3/writer/console/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ def write_value(tag: str, value: Optional[Union[bool, str, dict, list, Enum]], o

def write_and_possibly_indent(text: str, indent: bool, out: TextIO):
if indent:
out.write(f"\t{text}\n")
out.write(f" {text}\n")
else:
out.write(f"{text}\n")
45 changes: 45 additions & 0 deletions tests/spdx3/writer/tag_value/test_write_document.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# SPDX-FileCopyrightText: 2024 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
import io
stanislaw marked this conversation as resolved.
Show resolved Hide resolved
from datetime import datetime

from semantic_version import Version

from spdx_tools.spdx3.model import CreationInfo, ProfileIdentifierType, SpdxDocument
from spdx_tools.spdx3.writer.console.spdx_document_writer import write_spdx_document


def test_render_creation_info():
fake_datetime = datetime(year=2024, month=1, day=1)
spec_version = Version("3.0.0")
creation_info = CreationInfo(
spec_version=spec_version,
created=fake_datetime,
created_by=[],
profile=[ProfileIdentifierType.SOFTWARE],
)
spdx_document = SpdxDocument(
spdx_id="SPDXRef-FOO",
name="BAR",
element=[],
root_element=[],
creation_info=creation_info,
)
output_str = io.StringIO()
write_spdx_document(spdx_document, text_output=output_str)

assert (
output_str.getvalue()
== """\
## SPDX Document
SPDXID: SPDXRef-FOO
name: BAR
# Creation Information
specVersion: 3.0.0
created: 2024-01-01T00:00:00Z
profile: SOFTWARE
data license: CC0-1.0
elements:
""" # noqa: W291 # elements: are printed with a space
)
Loading