File tree 2 files changed +26
-2
lines changed
src/spdx_tools/spdx/parser/tagvalue
tests/spdx/parser/tagvalue
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,7 @@ def p_current_element_error(self, p):
180
180
"file_comment : FILE_COMMENT text_or_line\n "
181
181
"file_license_concluded : FILE_LICENSE_CONCLUDED license_or_no_assertion_or_none\n "
182
182
"package_name : PKG_NAME LINE\n description : PKG_DESCRIPTION text_or_line\n "
183
- "summary : PKG_SUMMARY text_or_line\n source_info : PKG_SOURCE_INFO text_or_line \n "
183
+ "summary : PKG_SUMMARY text_or_line\n source_info : PKG_SOURCE_INFO text_or_line_including_no_assertion \n "
184
184
"homepage : PKG_HOMEPAGE line_or_no_assertion_or_none\n "
185
185
"download_location : PKG_DOWNLOAD_LOCATION line_or_no_assertion_or_none\n "
186
186
"originator : PKG_ORIGINATOR actor_or_no_assertion\n supplier : PKG_SUPPLIER actor_or_no_assertion\n "
@@ -216,7 +216,11 @@ def p_unknown_tag(self, p):
216
216
def p_text (self , p ):
217
217
p [0 ] = str_from_text (p [1 ])
218
218
219
- @grammar_rule ("text_or_line : LINE\n line_or_no_assertion : LINE\n line_or_no_assertion_or_none : text_or_line" )
219
+ @grammar_rule (
220
+ "text_or_line : LINE\n line_or_no_assertion : LINE\n line_or_no_assertion_or_none : text_or_line\n "
221
+ "text_or_line_including_no_assertion : text_or_line\n text_or_line_including_no_assertion : NO_ASSERTION\n "
222
+ "text_or_line_including_no_assertion : NONE"
223
+ )
220
224
def p_line (self , p ):
221
225
p [0 ] = p [1 ]
222
226
Original file line number Diff line number Diff line change @@ -83,6 +83,26 @@ def test_parse_package():
83
83
assert package .valid_until_date == datetime (2022 , 1 , 1 , 12 )
84
84
85
85
86
+ def test_parse_package_with_no_assertion_as_source_info ():
87
+ parser = Parser ()
88
+ package_str = "\n " .join (
89
+ [
90
+ "PackageName: Test" ,
91
+ "SPDXID: SPDXRef-Package" ,
92
+ "PackageDownloadLocation: http://example.com/test" ,
93
+ "FilesAnalyzed: true" ,
94
+ "PackageSummary: <text>Test package</text>" ,
95
+ "PackageSourceInfo: NOASSERTION" ,
96
+ ]
97
+ )
98
+ document = parser .parse ("\n " .join ([DOCUMENT_STR , package_str ]))
99
+ assert document is not None
100
+ package = document .packages [0 ]
101
+ assert package .name == "Test"
102
+ assert package .spdx_id == "SPDXRef-Package"
103
+ assert package .source_info == "NOASSERTION"
104
+
105
+
86
106
@pytest .mark .parametrize (
87
107
"package_str, expected_message" ,
88
108
[
You can’t perform that action at this time.
0 commit comments