11import os
22import subprocess
3- import pytest
3+
44
55def run_command (command ):
6- process = subprocess .run (command , shell = True , capture_output = True , text = True )
7- success = (process .returncode == 0 )
6+ process = subprocess .run (command , shell = True , capture_output = True , text = True )
7+ success = (process .returncode == 0 )
88 return success , process .stdout if success else process .stderr
99
1010def test_run ():
1111 run_command ("rm -rf test_scan test_scan2 test_scan3" )
1212 os .makedirs ("test_scan" )
13- scan_success ,_ = run_command ("fosslight_source -p tests/test_files -j -m -o test_scan" )
14- scan_exclude_success ,_ = run_command ("fosslight_source -p tests -e test_files/test cli_test.py -j -m -o test_scan2" )
13+ scan_success , _ = run_command ("fosslight_source -p tests/test_files -j -m -o test_scan" )
14+ scan_exclude_success , _ = run_command ("fosslight_source -p tests -e test_files/test cli_test.py -j -m -o test_scan2" )
1515
16- scan_files = os .listdir ("test_scan" )
17- scan2_files = os .listdir ('test_scan2' )
16+ scan_files = os .listdir ("test_scan" )
17+ scan2_files = os .listdir ('test_scan2' )
1818
19- #then
2019 assert scan_success is True , "Test Run: Scan command failed"
2120 assert scan_exclude_success is True , "Test Run: Exclude command failed"
2221
23- assert len (scan_files )> 0 , "Test Run: No scan files created in test_scan directory"
24- assert len (scan2_files )> 0 , "Test Run: No scan files created in test_scan2 directory"
22+ assert len (scan_files ) > 0 , "Test Run: No scan files created in test_scan directory"
23+ assert len (scan2_files ) > 0 , "Test Run: No scan files created in test_scan2 directory"
2524
2625def test_help_command ():
2726 success , _ = run_command ("fosslight_source -h" )
2827 assert success is True , "Test Release: Help command failed "
2928
3029def test_scan_command ():
31- success ,_ = run_command ("fosslight_source -p tests/test_files -o test_scan/scan_result.csv" )
30+ success , _ = run_command ("fosslight_source -p tests/test_files -o test_scan/scan_result.csv" )
3231 assert success is True , "Test Release: Failed to generate scan result CSV file"
3332
3433 assert os .path .exists ("test_scan/scan_result.csv" ), "Test Release: scan_result.csv file not generated"
@@ -40,7 +39,7 @@ def test_scan_command():
4039 print (f"Content of scan_result.csv:\n { content } " )
4140
4241def test_exclude_command ():
43- success ,_ = run_command ("fosslight_source -p tests -e test_files/test cli_test.py -j -m -o test_scan2/scan_exclude_result.csv" )
42+ success , _ = run_command ("fosslight_source -p tests -e test_files/test cli_test.py -j -m -o test_scan2/scan_exclude_result.csv" )
4443 assert success is True , "Test release: Exclude scan failded"
4544
4645 assert os .path .exists ("test_scan2/scan_exclude_result.csv" ), "Test Release: scan_exclude_result.csv file not generated"
@@ -52,7 +51,7 @@ def test_exclude_command():
5251 print (f"Content of scan_exclude_result.csv:\n { content } " )
5352
5453def test_json_command ():
55- success ,_ = run_command ("fosslight_source -p tests/test_files -m -j -o test_scan3/" )
54+ success , _ = run_command ("fosslight_source -p tests/test_files -m -j -o test_scan3/" )
5655 assert success is True , "Test release: Failed to generate JSON files"
5756
5857def test_ls_test_scan3_command ():
@@ -61,6 +60,6 @@ def test_ls_test_scan3_command():
6160 print (f"Files in test_scan3: { files_in_test_scan3 } " )
6261
6362def test_flake8 ():
64- success ,_ = run_command ("flake8" )
63+ success , _ = run_command ("flake8" )
6564 assert success is True , "Flake8: Style check failed"
6665
0 commit comments