Skip to content

Commit e9df507

Browse files
committed
Regen CycloneDX expectation with metadata
Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 6a9576c commit e9df507

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

tests/formattedcode/data/cyclonedx/expected.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
<bom xmlns="http://cyclonedx.org/schema/bom/1.3" version="1" serialNumber="">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.3" version="1" serialNumber="urn:uuid:cd08d8e2-49b8-4baa-b7b2-c96258cb3aa5">
3+
<metadata>
4+
<timestamp>2022-04-20T17:16:54Z</timestamp>
5+
<tools>
6+
<tool>
7+
<vendor>AboutCode.org</vendor>
8+
<name>scancode-toolkit</name>
9+
<version>31.0.0b1</version>
10+
</tool>
11+
</tools>
12+
</metadata>
213
<components>
314
<component type="library" bom-ref="pkg:npm/[email protected]">
415
<name>npm</name>

tests/formattedcode/test_output_cyclonedx.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,13 @@ def check_cyclone_xml_output(expected_file, result_file, regen=REGEN_TEST_FIXTUR
6464
Check that expected and result_file are equal. Ignore headers.
6565
If `regen` is True the expected_file is overwritten with `results_file`.
6666
"""
67-
result = load_and_clean_xml(result_file)
6867
if regen:
69-
expected = result
70-
with open(expected_file, 'w') as o:
71-
o.write(result)
72-
else:
73-
expected = load_and_clean_xml(expected_file)
68+
with open(result_file) as rf, open(expected_file, 'w') as ef:
69+
expected = rf.read()
70+
ef.write(expected)
7471

72+
result = load_and_clean_xml(result_file)
73+
expected = load_and_clean_xml(expected_file)
7574
assert result == expected
7675

7776

0 commit comments

Comments
 (0)