Skip to content

Commit 535adc7

Browse files
committed
revise
Signed-off-by: hkkim <[email protected]>
1 parent fc93a34 commit 535adc7

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

tests/test_tox.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2020 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
15
import os
26
import 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

532
def run_command(command):
@@ -9,13 +36,15 @@ def run_command(command):
936

1037

1138
def 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

2150
def test_help_command():

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ deps =
3535
commands =
3636
pytest tests/test_tox.py::test_help_command tests/test_tox.py::test_scan_command \
3737
tests/test_tox.py::test_exclude_command tests/test_tox.py::test_json_command \
38-
tests/test_tox.py::test_ls_test_scan3_command \
3938
--maxfail=1 --disable-warnings
4039

4140
python tests/cli_test.py

0 commit comments

Comments
 (0)