Skip to content

Commit

Permalink
Ignore UUIDs in SPDX namespeca tests aboutcode-org#2344
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
  • Loading branch information
pombredanne committed Jun 17, 2021
1 parent 1029068 commit e6c3957
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/formattedcode/data/spdx/simple/expected.tv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SPDXVersion: SPDX-2.1
DataLicense: CC0-1.0
SPDXID: SPDXRef-DOCUMENT
DocumentNamespace: http://spdx.org/spdxdocs/simple-95546eef-3081-4c4b-bd90-c899c395adaf
DocumentNamespace: http://spdx.org/spdxdocs/simple
DocumentComment: <text>Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES
OR CONDITIONS OF ANY KIND, either express or implied. No content created from
ScanCode should be considered or used as legal advice. Consult an Attorney
Expand Down
23 changes: 19 additions & 4 deletions tests/formattedcode/test_output_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def sort_nested(data):
maptypes = dict, dict
coltypes = seqtypes + maptypes


if isinstance(data, maptypes):
new_data = []
for k, v in data.items():
Expand Down Expand Up @@ -138,9 +137,25 @@ def load_and_clean_tv(location):
"""
with io.open(location, encoding='utf-8') as co:
content = co.read()
content = [l for l in content.splitlines(False)
if l and l.strip() and not l.startswith(('Creator: ', 'Created: ',))]
return '\n'.join(content)
lines = []
lines_append = lines.append

dns = 'DocumentNamespace: http://spdx.org/spdxdocs/'

for line in content.splitlines(False):
line = line.strip()
if not line:
continue
if line.startswith(('Creator: ', 'Created: ',)):
continue
if line.startswith(dns):
# only keep the left side of
# DocumentNamespace: http://spdx.org/spdxdocs/unicode-ea31be0f-16de-4eab-9fc7-4e3bafb753d3
line, _, _ = line.partition('-')

lines_append(line)

return '\n'.join(lines)


def check_tv_scan(expected_file, result_file, regen=False):
Expand Down

0 comments on commit e6c3957

Please sign in to comment.