Skip to content

Commit f25bd4c

Browse files
[issue-402] change write_document() to write_document_to_file()
Signed-off-by: Armin Tänzer <[email protected]>
1 parent 780c94f commit f25bd4c

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/spdx/writer/json/json_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from spdx.validation.validation_message import ValidationMessage
1111

1212

13-
def write_document(document: Document, file_name: str, validate: bool = True, converter: DocumentConverter = None):
13+
def write_document_to_file(document: Document, file_name: str, validate: bool = True, converter: DocumentConverter = None):
1414
"""
1515
Serializes the provided document to json and writes it to a file with the provided name. Unless validate is set
1616
to False, validates the document before serialization. Unless a DocumentConverter instance is provided,

src/spdx/writer/write_anything.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def write_file(document: Document, file_name: str, validate: bool = True):
1414
output_format = file_name_to_format(file_name)
1515
if output_format == FileFormat.JSON:
16-
json_writer.write_document(document, file_name, validate)
16+
json_writer.write_document_to_file(document, file_name, validate)
1717
elif output_format == FileFormat.YAML:
1818
yaml_writer.write_document_to_file(document, file_name, validate)
1919
elif output_format == FileFormat.XML:

tests/spdx/writer/json/test_json_writer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88

9-
from spdx.writer.json.json_writer import write_document
9+
from spdx.writer.json.json_writer import write_document_to_file
1010
from tests.spdx.fixtures import document_fixture
1111

1212

@@ -19,7 +19,7 @@ def temporary_file_path() -> str:
1919

2020
def test_write_json(temporary_file_path: str):
2121
document = document_fixture()
22-
write_document(document, temporary_file_path, validate=True)
22+
write_document_to_file(document, temporary_file_path, validate=True)
2323

2424
with open(temporary_file_path) as written_file:
2525
written_json = json.load(written_file)
@@ -35,12 +35,12 @@ def test_document_is_validated():
3535
document.creation_info.spdx_id = "InvalidId"
3636

3737
with pytest.raises(ValueError) as error:
38-
write_document(document, "dummy_path")
38+
write_document_to_file(document, "dummy_path")
3939
assert "Document is not valid" in error.value.args[0]
4040

4141

4242
def test_document_validation_can_be_overridden(temporary_file_path: str):
4343
document = document_fixture()
4444
document.creation_info.spdx_id = "InvalidId"
4545

46-
write_document(document, temporary_file_path, validate=False)
46+
write_document_to_file(document, temporary_file_path, validate=False)

0 commit comments

Comments
 (0)