1+ #!/usr/bin/env python
2+ # -*- coding: utf-8 -*-
3+ # Copyright (c) 2020 LG Electronics Inc.
4+ # SPDX-License-Identifier: Apache-2.0
15import os
26import subprocess
7+ import pytest
8+ import shutil
9+
10+ set_up_directories = [
11+ "test_scan" ,
12+ "test_scan2" ,
13+ "test_scan3"
14+ ]
15+ remove_directories = ["test_scan" , "test_scan2" , "test_scan3" ]
16+
17+
18+ @pytest .fixture (scope = "module" , autouse = True )
19+ def setup_test_result_dir_and_teardown ():
20+ print ("==============setup==============" )
21+ for dir in set_up_directories :
22+ os .makedirs (dir , exist_ok = True )
23+
24+ yield
25+
26+ print ("==============tearDown==============" )
27+ for dir in remove_directories :
28+ if os .path .exists (dir ):
29+ shutil .rmtree (dir )
330
431
532def run_command (command ):
@@ -9,13 +36,15 @@ def run_command(command):
936
1037
1138def test_run ():
12- run_command ("rm -rf test_scan test_scan2 test_scan3" )
13- os .makedirs ("test_scan" , exist_ok = True )
1439 scan_success , _ = run_command ("fosslight_source -p tests/test_files -j -m -o test_scan" )
1540 scan_exclude_success , _ = run_command ("fosslight_source -p tests -e test_files/test cli_test.py -j -m -o test_scan2" )
41+ scan_files = os .listdir ("test_scan" )
42+ scan2_files = os .listdir ('test_scan2' )
1643
1744 assert scan_success is True , "Test Run: Scan command failed"
1845 assert scan_exclude_success is True , "Test Run: Exclude command failed"
46+ assert len (scan_files ) > 0 , "Test Run: No scan files created in test_scan directory"
47+ assert len (scan2_files ) > 0 , "Test Run: No scan files created in test_scan2 directory"
1948
2049
2150def test_help_command ():
0 commit comments