Skip to content

Commit 5bdde3d

Browse files
author
Meret Behrens
committed
[review] use double quotes
Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
1 parent c2a2895 commit 5bdde3d

9 files changed

Lines changed: 400 additions & 398 deletions

tests/spdx/parser/tagvalue/test_annotation_parser.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,40 @@
2020

2121
def test_parse_annotation():
2222
parser = Parser()
23-
annotation_str = '\n'.join([
24-
'Annotator: Person: Jane Doe()',
25-
'AnnotationDate: 2010-01-29T18:30:22Z',
26-
'AnnotationComment: <text>Document level annotation</text>',
27-
'AnnotationType: OTHER',
28-
'SPDXREF: SPDXRef-DOCUMENT'
23+
annotation_str = "\n".join([
24+
"Annotator: Person: Jane Doe()",
25+
"AnnotationDate: 2010-01-29T18:30:22Z",
26+
"AnnotationComment: <text>Document level annotation</text>",
27+
"AnnotationType: OTHER",
28+
"SPDXREF: SPDXRef-DOCUMENT"
2929
])
3030
document = parser.parse("\n".join([DOCUMENT_STR, annotation_str]))
3131
assert document is not None
3232
assert len(document.annotations) == 1
3333
annotation = document.annotations[0]
34-
assert annotation.annotator.name == 'Jane Doe'
34+
assert annotation.annotator.name == "Jane Doe"
3535
assert annotation.annotation_date == datetime(2010, 1, 29, 18, 30, 22)
36-
assert annotation.annotation_comment == 'Document level annotation'
36+
assert annotation.annotation_comment == "Document level annotation"
3737
assert annotation.annotation_type == AnnotationType.OTHER
38-
assert annotation.spdx_id == 'SPDXRef-DOCUMENT'
38+
assert annotation.spdx_id == "SPDXRef-DOCUMENT"
3939

4040

4141
@pytest.mark.parametrize("annotation_str, expected_message", [
42-
('Annotator: Person: Jane Doe()', r"__init__() missing 4 "
42+
("Annotator: Person: Jane Doe()", r"__init__() missing 4 "
4343
"required positional arguments: 'spdx_id', 'annotation_type', "
4444
"'annotation_date', and 'annotation_comment'"),
45-
('Annotator: Person: Jane Doe()\nAnnotationType: SOURCE\nAnnotationDate: 201001-2912:23',
45+
("Annotator: Person: Jane Doe()\nAnnotationType: SOURCE\nAnnotationDate: 201001-2912:23",
4646
"Error while parsing Annotation: ['Invalid AnnotationType: SOURCE. Line: 2', "
4747
"'Error while parsing AnnotationDate: Token did not match specified grammar "
4848
"rule. Line: 3']"),
49-
('Annotator: Jane Doe()\nAnnotationDate: 201001-29T18:30:22Z\n'
50-
'AnnotationComment: <text>Document level annotation</text>\nAnnotationType: OTHER\nSPDXREF: SPDXRef-DOCUMENT',
49+
("Annotator: Jane Doe()\nAnnotationDate: 201001-29T18:30:22Z\n"
50+
"AnnotationComment: <text>Document level annotation</text>\nAnnotationType: OTHER\nSPDXREF: SPDXRef-DOCUMENT",
5151
"Error while parsing Annotation: ['Error while parsing Annotator: Token did "
5252
"not match specified grammar rule. Line: 1', 'Error while parsing "
5353
"AnnotationDate: Token did not match specified grammar rule. Line: 2']"),
54-
('Annotator: Person: ()', "Error while parsing Annotation: [['No name for Person provided: Person: ().']]"),
55-
('AnnotationType: REVIEW', 'Element Annotation is not the current element in scope, probably the '
56-
'expected tag to start the element (Annotator) is missing. Line: 1')])
54+
("Annotator: Person: ()", "Error while parsing Annotation: [['No name for Person provided: Person: ().']]"),
55+
("AnnotationType: REVIEW", "Element Annotation is not the current element in scope, probably the "
56+
"expected tag to start the element (Annotator) is missing. Line: 1")])
5757
def test_parse_invalid_annotation(annotation_str, expected_message):
5858
parser = Parser()
5959
with pytest.raises(SPDXParsingError) as err:

tests/spdx/parser/tagvalue/test_creation_info_parser.py

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
from spdx.parser.error import SPDXParsingError
2121
from spdx.parser.tagvalue.parser import Parser
2222

23-
DOCUMENT_STR = '\n'.join([
24-
'SPDXVersion: SPDX-2.3',
25-
'DataLicense: CC0-1.0',
26-
'DocumentName: Sample_Document-V2.3',
27-
'SPDXID: SPDXRef-DOCUMENT',
28-
'DocumentComment: <text>Sample Comment</text>',
29-
'DocumentNamespace: https://spdx.org/spdxdocs/spdx-example-444504E0-4F89-41D3-9A0C-0305E82C3301',
30-
'ExternalDocumentRef: DocumentRef-spdx-tool-1.2 http://spdx.org/spdxdocs/spdx-tools-v1.2-3F2504E0-4F89-41D3-9A0C-0305E82C3301 SHA1: d6a770ba38583ed4bb4525bd96e50461655d2759',
31-
'Creator: Person: Bob (bob@example.com)',
32-
'Creator: Organization: Acme.',
33-
'Created: 2010-02-03T00:00:00Z',
34-
'CreatorComment: <text>Sample Comment \nwith multiple \nlines.</text>',
35-
'LicenseListVersion: 3.17'
23+
DOCUMENT_STR = "\n".join([
24+
"SPDXVersion: SPDX-2.3",
25+
"DataLicense: CC0-1.0",
26+
"DocumentName: Sample_Document-V2.3",
27+
"SPDXID: SPDXRef-DOCUMENT",
28+
"DocumentComment: <text>Sample Comment</text>",
29+
"DocumentNamespace: https://spdx.org/spdxdocs/spdx-example-444504E0-4F89-41D3-9A0C-0305E82C3301",
30+
"ExternalDocumentRef: DocumentRef-spdx-tool-1.2 http://spdx.org/spdxdocs/spdx-tools-v1.2-3F2504E0-4F89-41D3-9A0C-0305E82C3301 SHA1: d6a770ba38583ed4bb4525bd96e50461655d2759",
31+
"Creator: Person: Bob (bob@example.com)",
32+
"Creator: Organization: Acme.",
33+
"Created: 2010-02-03T00:00:00Z",
34+
"CreatorComment: <text>Sample Comment \nwith multiple \nlines.</text>",
35+
"LicenseListVersion: 3.17"
3636
])
3737

3838

@@ -43,15 +43,15 @@ def test_parse_creation_info():
4343
creation_info = document.creation_info
4444
assert creation_info is not None
4545
assert creation_info.spdx_version == "SPDX-2.3"
46-
assert creation_info.data_license == 'CC0-1.0'
47-
assert creation_info.name == 'Sample_Document-V2.3'
48-
assert creation_info.spdx_id == 'SPDXRef-DOCUMENT'
49-
assert creation_info.document_comment == 'Sample Comment'
50-
assert creation_info.document_namespace == 'https://spdx.org/spdxdocs/spdx-example-444504E0-4F89-41D3-9A0C-0305E82C3301'
46+
assert creation_info.data_license == "CC0-1.0"
47+
assert creation_info.name == "Sample_Document-V2.3"
48+
assert creation_info.spdx_id == "SPDXRef-DOCUMENT"
49+
assert creation_info.document_comment == "Sample Comment"
50+
assert creation_info.document_namespace == "https://spdx.org/spdxdocs/spdx-example-444504E0-4F89-41D3-9A0C-0305E82C3301"
5151
TestCase().assertCountEqual(creation_info.creators,
5252
[Actor(ActorType.PERSON, "Bob", "bob@example.com"),
5353
Actor(ActorType.ORGANIZATION, "Acme.")])
54-
assert creation_info.creator_comment == 'Sample Comment \nwith multiple \nlines.'
54+
assert creation_info.creator_comment == "Sample Comment \nwith multiple \nlines."
5555
assert creation_info.created == datetime(2010, 2, 3)
5656
assert creation_info.license_list_version == Version(3, 17)
5757
assert creation_info.external_document_refs == [ExternalDocumentRef("DocumentRef-spdx-tool-1.2",
@@ -61,28 +61,28 @@ def test_parse_creation_info():
6161

6262

6363
@pytest.mark.parametrize("document_str, expected_message",
64-
([('\n'.join(
65-
['SPDXVersion: SPDX-2.3', 'DataLicense: CC0-1.0', 'DocumentName: Sample_Document-V2.3',
66-
'SPDXID: SPDXRef-DOCUMENT', 'DocumentComment: <text>Sample Comment</text>',
67-
'DocumentNamespace: <text>Sample Comment</text>',
68-
'ExternalDocumentRef: DocumentRef-spdx-tool-1.2:htp://spdx.org:SHA1: d6a770ba38583ed4bb4525bd96e50461655d2759',
69-
'Creator: Person Bob (bob@example.com)', 'Creator: Organization: Acme [email]',
70-
'Created: 2010-02-03T00:00:0Z', 'CreatorComment: <text>Sample Comment</text>',
71-
'LicenseListVersion: 7']),
72-
"Error while parsing CreationInfo: "
73-
"['Error while parsing DocumentNamespace: Token did not match specified grammar rule. "
74-
"Line: 6', 'Error while parsing ExternalDocumentRef: "
75-
"Token did not match specified grammar rule. Line: 7', 'Error while parsing Creator: "
76-
"Token did not match specified grammar rule. Line: 8', 'Error while parsing Created: "
77-
"Token did not match specified grammar rule. Line: 10', '7 is not a valid version string']"),
78-
('\n'.join(
79-
['SPDXVersion: SPDX-2.3', 'DataLicense: CC0-1.0', 'DocumentName: Sample_Document-V2.3',
80-
'SPDXID: SPDXRef-DOCUMENT']),
81-
r"__init__() missing 3 required positional arguments: "
82-
r"'document_namespace', 'creators', and 'created'"),
83-
('LicenseListVersion: 3.5\nLicenseListVersion: 3.7',
84-
"Error while parsing CreationInfo: ['Multiple values for LicenseListVersion "
85-
"found. Line: 2']")]))
64+
([("\n".join(
65+
["SPDXVersion: SPDX-2.3", "DataLicense: CC0-1.0", "DocumentName: Sample_Document-V2.3",
66+
"SPDXID: SPDXRef-DOCUMENT", "DocumentComment: <text>Sample Comment</text>",
67+
"DocumentNamespace: <text>Sample Comment</text>",
68+
"ExternalDocumentRef: DocumentRef-spdx-tool-1.2:htp://spdx.org:SHA1: d6a770ba38583ed4bb4525bd96e50461655d2759",
69+
"Creator: Person Bob (bob@example.com)", "Creator: Organization: Acme [email]",
70+
"Created: 2010-02-03T00:00:0Z", "CreatorComment: <text>Sample Comment</text>",
71+
"LicenseListVersion: 7"]),
72+
"Error while parsing CreationInfo: ['Error while parsing DocumentNamespace: "
73+
"Token did not match specified grammar rule. Line: 6', 'Error while parsing "
74+
"ExternalDocumentRef: Token did not match specified grammar rule. Line: 7', "
75+
"'Error while parsing Creator: Token did not match specified grammar rule. Line: 8', "
76+
"'Error while parsing Created: Token did not match specified grammar rule. Line: 10', "
77+
"'7 is not a valid version string']"),
78+
("\n".join(
79+
["SPDXVersion: SPDX-2.3", "DataLicense: CC0-1.0", "DocumentName: Sample_Document-V2.3",
80+
"SPDXID: SPDXRef-DOCUMENT"]),
81+
r"__init__() missing 3 required positional arguments: 'document_namespace', "
82+
r"'creators', and 'created'"),
83+
("LicenseListVersion: 3.5\nLicenseListVersion: 3.7",
84+
"Error while parsing CreationInfo: ['Multiple values for LicenseListVersion found. "
85+
"Line: 2']")]))
8686
def test_parse_invalid_creation_info(document_str, expected_message):
8787
parser = Parser()
8888
with pytest.raises(SPDXParsingError) as err:

tests/spdx/parser/tagvalue/test_extracted_licensing_info_parser.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@
1919

2020
def test_parse_extracted_licensing_info():
2121
parser = Parser()
22-
extracted_licensing_info_str = '\n'.join([
23-
'LicenseID: LicenseRef-Beerware-4.2',
24-
'ExtractedText: <text>"THE BEER-WARE LICENSE" (Revision 42): phk@FreeBSD.ORG wrote this file. As long as you '
25-
'retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this '
26-
'stuff is worth it, you can buy me a beer in return Poul-Henning Kamp</text>'
27-
'LicenseName: Beer-Ware License (Version 42)',
28-
'LicenseCrossReference: http://people.freebsd.org/~phk/',
29-
'LicenseCrossReference: http://another.cross.reference/',
30-
'LicenseComment: The beerware license has a couple of other standard variants.'
22+
extracted_licensing_info_str = "\n".join([
23+
"LicenseID: LicenseRef-Beerware-4.2",
24+
"ExtractedText: <text>\"THE BEER-WARE LICENSE\" (Revision 42): phk@FreeBSD.ORG wrote this file. As long as you "
25+
"retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this "
26+
"stuff is worth it, you can buy me a beer in return Poul-Henning Kamp</text>"
27+
"LicenseName: Beer-Ware License (Version 42)",
28+
"LicenseCrossReference: http://people.freebsd.org/~phk/",
29+
"LicenseCrossReference: http://another.cross.reference/",
30+
"LicenseComment: The beerware license has a couple of other standard variants."
3131
])
3232
document = parser.parse("\n".join([DOCUMENT_STR, extracted_licensing_info_str]))
3333
assert document is not None
3434
assert len(document.extracted_licensing_info) == 1
3535
extracted_licensing_info = document.extracted_licensing_info[0]
3636
assert extracted_licensing_info.license_id == "LicenseRef-Beerware-4.2"
37-
assert extracted_licensing_info.extracted_text == '"THE BEER-WARE LICENSE" (Revision 42): phk@FreeBSD.ORG wrote this file. ' \
38-
'As long as you retain this notice you can do whatever you want with this stuff. ' \
39-
'If we meet some day, and you think this stuff is worth it, you can buy me a beer in return Poul-Henning Kamp'
37+
assert extracted_licensing_info.extracted_text == "\"THE BEER-WARE LICENSE\" (Revision 42): phk@FreeBSD.ORG wrote this file. " \
38+
"As long as you retain this notice you can do whatever you want with this stuff. " \
39+
"If we meet some day, and you think this stuff is worth it, you can buy me a beer in return Poul-Henning Kamp"
4040
assert extracted_licensing_info.license_name == "Beer-Ware License (Version 42)"
4141
TestCase().assertCountEqual(extracted_licensing_info.cross_references,
4242
["http://people.freebsd.org/~phk/", "http://another.cross.reference/"])
@@ -45,20 +45,22 @@ def test_parse_extracted_licensing_info():
4545

4646
def test_parse_invalid_extracted_licensing_info():
4747
parser = Parser()
48-
extracted_licensing_info_str = '\n'.join([
49-
'ExtractedText: <text>"THE BEER-WARE LICENSE" (Revision 42): phk@FreeBSD.ORG wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return Poul-Henning Kamp</text>'
50-
'LicenseName: Beer-Ware License (Version 42)',
51-
'LicenseCrossReference: http://people.freebsd.org/~phk/',
52-
'LicenseComment: The beerware license has a couple of other standard variants.'])
48+
extracted_licensing_info_str = "\n".join([
49+
"ExtractedText: <text>\"THE BEER-WARE LICENSE\" (Revision 42): phk@FreeBSD.ORG wrote this file. "
50+
"As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you "
51+
"think this stuff is worth it, you can buy me a beer in return Poul-Henning Kamp</text>"
52+
"LicenseName: Beer-Ware License (Version 42)",
53+
"LicenseCrossReference: http://people.freebsd.org/~phk/",
54+
"LicenseComment: The beerware license has a couple of other standard variants."])
5355

5456
with pytest.raises(SPDXParsingError) as err:
5557
parser.parse(extracted_licensing_info_str)
5658

57-
assert err.value.get_messages() == ['Element ExtractedLicensingInfo is not the current element in scope, probably '
58-
'the expected tag to start the element (LicenseID) is missing. Line: 1',
59-
'Element ExtractedLicensingInfo is not the current element in scope, probably '
60-
'the expected tag to start the element (LicenseID) is missing. Line: 2',
61-
'Element ExtractedLicensingInfo is not the current element in scope, probably '
62-
'the expected tag to start the element (LicenseID) is missing. Line: 3',
63-
'Element ExtractedLicensingInfo is not the current element in scope, probably '
64-
'the expected tag to start the element (LicenseID) is missing. Line: 4']
59+
assert err.value.get_messages() == ["Element ExtractedLicensingInfo is not the current element in scope, probably "
60+
"the expected tag to start the element (LicenseID) is missing. Line: 1",
61+
"Element ExtractedLicensingInfo is not the current element in scope, probably "
62+
"the expected tag to start the element (LicenseID) is missing. Line: 2",
63+
"Element ExtractedLicensingInfo is not the current element in scope, probably "
64+
"the expected tag to start the element (LicenseID) is missing. Line: 3",
65+
"Element ExtractedLicensingInfo is not the current element in scope, probably "
66+
"the expected tag to start the element (LicenseID) is missing. Line: 4"]

tests/spdx/parser/tagvalue/test_file_parser.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,45 @@
1919

2020
def test_parse_file():
2121
parser = Parser()
22-
file_str = '\n'.join([
23-
'FileName: testfile.java',
24-
'SPDXID: SPDXRef-File',
25-
'FileType: SOURCE',
26-
'FileType: TEXT',
27-
'FileChecksum: SHA1: 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12',
28-
'LicenseConcluded: Apache-2.0',
29-
'LicenseInfoInFile: Apache-2.0',
30-
'FileCopyrightText: <text>Copyright 2014 Acme Inc.</text>',
31-
'FileComment: <text>Very long file</text>',
32-
'FileAttributionText: <text>Acknowledgements that might be required to be communicated in some contexts.</text>'
22+
file_str = "\n".join([
23+
"FileName: testfile.java",
24+
"SPDXID: SPDXRef-File",
25+
"FileType: SOURCE",
26+
"FileType: TEXT",
27+
"FileChecksum: SHA1: 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
28+
"LicenseConcluded: Apache-2.0",
29+
"LicenseInfoInFile: Apache-2.0",
30+
"FileCopyrightText: <text>Copyright 2014 Acme Inc.</text>",
31+
"FileComment: <text>Very long file</text>",
32+
"FileAttributionText: <text>Acknowledgements that might be required to be communicated in some contexts.</text>"
3333
])
3434
document = parser.parse("\n".join([DOCUMENT_STR, file_str]))
3535
assert document is not None
3636
assert len(document.files) == 1
3737
spdx_file = document.files[0]
38-
assert spdx_file.name == 'testfile.java'
39-
assert spdx_file.spdx_id == 'SPDXRef-File'
38+
assert spdx_file.name == "testfile.java"
39+
assert spdx_file.spdx_id == "SPDXRef-File"
4040
assert spdx_file.file_type == [FileType.SOURCE, FileType.TEXT]
41-
assert spdx_file.comment == 'Very long file'
41+
assert spdx_file.comment == "Very long file"
4242
assert spdx_file.attribution_texts == [
43-
'Acknowledgements that might be required to be communicated in some contexts.']
43+
"Acknowledgements that might be required to be communicated in some contexts."]
4444
assert spdx_file.license_info_in_file == [get_spdx_licensing().parse("Apache-2.0")]
4545
assert spdx_file.license_concluded == get_spdx_licensing().parse("Apache-2.0")
4646

4747

4848
def test_parse_invalid_file():
4949
parser = Parser()
50-
file_str = '\n'.join([
51-
'FileName: testfile.java',
52-
'SPDXID: SPDXRef-File',
53-
'FileType: SOUCE',
54-
'FileType: TEXT',
55-
'FileChecksum: SHA3: 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12',
56-
'LicenseConcluded: Apache-2.0',
57-
'LicenseInfoInFile: Apache-2.0',
58-
'FileCopyrightText: <text>Copyright 2014 Acme Inc.</text>',
59-
'FileComment: <text>Very long file</text>',
60-
'FileAttributionText: <text>Acknowledgements that might be required to be communicated in some contexts.</text>'
50+
file_str = "\n".join([
51+
"FileName: testfile.java",
52+
"SPDXID: SPDXRef-File",
53+
"FileType: SOUCE",
54+
"FileType: TEXT",
55+
"FileChecksum: SHA3: 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
56+
"LicenseConcluded: Apache-2.0",
57+
"LicenseInfoInFile: Apache-2.0",
58+
"FileCopyrightText: <text>Copyright 2014 Acme Inc.</text>",
59+
"FileComment: <text>Very long file</text>",
60+
"FileAttributionText: <text>Acknowledgements that might be required to be communicated in some contexts.</text>"
6161
])
6262

6363
with pytest.raises(SPDXParsingError) as err:

0 commit comments

Comments
 (0)