1111def cleanup_output_files ():
1212 yield
1313
14- files_to_delete = ["spdx2_to_3.jsonld" , "my_spdx_document.spdx.json" , "converted_format.xml" ]
14+ files_to_delete = ["spdx2_to_3.jsonld" , "my_spdx_document.spdx.json" , "converted_format.xml" , "graph.png" ]
1515 for file in files_to_delete :
1616 output_file = os .path .join (os .path .dirname (__file__ ), file )
1717 if os .path .exists (output_file ):
@@ -27,25 +27,39 @@ def test_spdx2_parse_file():
2727 run_example ("spdx2_parse_file.py" )
2828
2929
30- @pytest .mark .usefixtures (' cleanup_output_files' )
30+ @pytest .mark .usefixtures (" cleanup_output_files" )
3131def test_spdx2_convert_to_spdx3 ():
3232 run_example ("spdx2_convert_to_spdx3.py" )
3333
3434 output_file = os .path .join (os .path .dirname (__file__ ), "spdx2_to_3.jsonld" )
3535 assert os .path .exists (output_file )
3636
3737
38- @pytest .mark .usefixtures (' cleanup_output_files' )
38+ @pytest .mark .usefixtures (" cleanup_output_files" )
3939def test_spdx2_document_from_scratch ():
4040 run_example ("spdx2_document_from_scratch.py" )
4141
4242 output_file = os .path .join (os .path .dirname (__file__ ), "my_spdx_document.spdx.json" )
4343 assert os .path .exists (output_file )
4444
4545
46- @pytest .mark .usefixtures (' cleanup_output_files' )
46+ @pytest .mark .usefixtures (" cleanup_output_files" )
4747def test_spdx2_convert_format ():
4848 run_example ("spdx2_convert_format.py" )
4949
5050 output_file = os .path .join (os .path .dirname (__file__ ), "converted_format.xml" )
5151 assert os .path .exists (output_file )
52+
53+
54+ @pytest .mark .usefixtures ("cleanup_output_files" )
55+ def test_spdx2_generate_graph ():
56+ try :
57+ import networkx # noqa F401
58+ import pygraphviz # noqa F401
59+ except ImportError :
60+ pytest .skip ("Missing optional dependencies" )
61+
62+ run_example ("spdx2_generate_graph.py" )
63+
64+ output_file = os .path .join (os .path .dirname (__file__ ), "graph.png" )
65+ assert os .path .exists (output_file )
0 commit comments