From 0011cce5db6a75a26af70bfe0f9ef1fb566dfd05 Mon Sep 17 00:00:00 2001 From: s-cu-bot Date: Sun, 15 Sep 2024 02:00:27 +0900 Subject: [PATCH 01/12] test-code revision Signed-off-by: s-cu-bot --- tests/initial_tox_test.py | 42 +++++++++++++++++++++++++++++++++++++++ tox.ini | 15 ++------------ 2 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 tests/initial_tox_test.py diff --git a/tests/initial_tox_test.py b/tests/initial_tox_test.py new file mode 100644 index 0000000..1f11866 --- /dev/null +++ b/tests/initial_tox_test.py @@ -0,0 +1,42 @@ +import os +import subprocess + +def run_command(command): #리눅스 명령어 실행 + result = subprocess.run(command, shell=True, capture_output=True, text=True) + success = result.returncode == 0 + output = result.stdout if success else result.stderr + return success, output + +def test_test_run_environment(): #테스트 환경 tox.ini + # Given + run_command("rm -rf test_result") + os.makedirs("test_result", exist_ok=True) + + # When + csv_success, _ = run_command("fosslight_bin -p tests -o test_result -f csv") + exclude_success, _ = run_command("fosslight_bin -p tests -e test commons-logging-1.2.jar -o test_result/exclude_result.csv -f csv") + files_in_result = run_command("ls test_result/")[1].split() + txt_success, txt_output = run_command("bash -c 'find test_result -type f -name \"fosslight_binary*.txt\"'") + + # Then + csv_files = [f for f in files_in_result if f.endswith('.csv')] + txt_files = txt_output.split() + success = csv_success and exclude_success and len(csv_files) > 0 and len(txt_files) > 0 + assert success is True, "Test Run Environment: CSV and TXT files not properly created" + +def test_release_environment(): #릴리즈 환경 tox.ini + # Given + os.makedirs("test_result", exist_ok=True) + + # When + help_success, _ = run_command("fosslight_bin -h") + csv_success, _ = run_command("fosslight_bin -p tests -o test_result/result.csv -f csv") + exclude_csv_success, _ = run_command("fosslight_bin -p tests -e test commons-logging-1.2.jar -o test_result/exclude_result.csv -f csv") + json_success, _ = run_command("fosslight_bin -p tests -o test_result/result.json -f opossum") + files_in_result = run_command("ls test_result/")[1].split() + + # Then + required_files = ['result.csv', 'exclude_result.csv', 'result.json'] + files_exist = all(f in files_in_result for f in required_files) + success = help_success and csv_success and exclude_csv_success and json_success and files_exist + assert success is True, "Release Environment: Required files not found or failed to execute" \ No newline at end of file diff --git a/tox.ini b/tox.ini index 7f15234..78b5450 100644 --- a/tox.ini +++ b/tox.ini @@ -25,25 +25,14 @@ filterwarnings = ignore::DeprecationWarning [testenv:test_run] commands = - rm -rf test_result - fosslight_bin -p tests -o test_result -f csv - fosslight_bin -p tests -e test commons-logging-1.2.jar -o test_result/exclude_result.csv -f csv - ls test_result/ - bash -c 'find test_result -type f -name "fosslight_report*.csv" | xargs cat' - bash -c 'find test_result -type f -name "fosslight_binary*.txt" | xargs cat' + python initial_tox_test.py::test_test_run_environment [testenv:release] deps = -r{toxinidir}/requirements-dev.txt commands = - fosslight_bin -h - fosslight_bin -p tests -o test_result/result.csv -f csv - fosslight_bin -p tests -e test commons-logging-1.2.jar -o test_result/exclude_result.csv -f csv - ls test_result/ - cat test_result/result.csv - cat test_result/exclude_result.csv - fosslight_bin -p tests -o test_result/result.json -f opossum + python initial_tox_test.py::test_release_environment pytest -v --flake8 pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --hidden-import=pkg_resources.extern {toxinidir}/dist/cli -p tests -o test_result_cli From 344909d3784f3538b202825e0ca890dbb71ccb4c Mon Sep 17 00:00:00 2001 From: s-cu-bot Date: Sun, 22 Sep 2024 22:29:47 +0900 Subject: [PATCH 02/12] test-code revision Signed-off-by: s-cu-bot --- requirements-dev.txt | 1 + tests/initial_tox_test.py | 51 +++++++++++++++++++++++++++++++++++++++ tox.ini | 20 ++++----------- 3 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 tests/initial_tox_test.py diff --git a/requirements-dev.txt b/requirements-dev.txt index 5d3baed..6bf06d2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,4 +3,5 @@ tox pytest pytest-cov pytest-flake8 +pytest-xdist flake8==3.9.2 \ No newline at end of file diff --git a/tests/initial_tox_test.py b/tests/initial_tox_test.py new file mode 100644 index 0000000..15e21c9 --- /dev/null +++ b/tests/initial_tox_test.py @@ -0,0 +1,51 @@ +import os +import subprocess + + +def run_command(command): # 리눅스 명령어 실행 + result = subprocess.run(command, shell=True, capture_output=True, text=True) + success = result.returncode == 0 + output = result.stdout if success else result.stderr + return success, output + + +def test_test_run_environment(): # 테스트 환경 tox.ini + # Given + run_command("rm -rf test_result") + os.makedirs("test_result", exist_ok=True) + + # When + csv_success, _ = run_command("fosslight_bin -p . -o test_result -f csv") + exclude_success, _ = run_command("fosslight_bin -p . -e test commons-logging-1.2.jar -o test_result/exclude_result.csv -f csv") + files_in_result = run_command("ls test_result/")[1].split() + txt_success, txt_output = run_command("bash -c 'find test_result -type f -name \"fosslight_log*.txt\"'") + + # Then + csv_files = [f for f in files_in_result if f.endswith('.csv')] + txt_files = txt_output.split() + assert csv_success is True, "Test Run Environment: CSV files not properly created (not create)" + assert len(csv_files) > 0, "Test Run Environment: CSV files not properly created (length)" + assert exclude_success is True, "Test Run Environment: Exclude feature fail" + assert len(txt_files) > 0, "Test Run Environment: txt files not properly created" + + +def test_release_environment(): # 릴리즈 환경 tox.ini + # Given + run_command("rm -rf test_result") + os.makedirs("test_result", exist_ok=True) + + # When + help_success, _ = run_command("fosslight_bin -h") + csv_success, _ = run_command("fosslight_bin -p . -o test_result/result.csv -f csv") + exclude_csv_success, _ = run_command("fosslight_bin -p . -e test commons-logging-1.2.jar -o test_result/exclude_result.csv -f csv") + json_success, _ = run_command("fosslight_bin -p . -o test_result/result.json -f opossum") + files_in_result = run_command("ls test_result/")[1].split() + + # Then + required_files = ['result.csv', 'exclude_result.csv', 'result.json'] + files_exist = all(f in files_in_result for f in required_files) + assert help_success is True, "Release Run Environment: help method not properly processing" + assert csv_success is True, "Release Run Environment: CSV files not properly created" + assert exclude_csv_success is True, "Release Run Environment: Exclude feature fail" + assert json_success is True, "Release Run Environment: json files not properly created" + assert files_exist is True, "Release Run Environment: Required files not properly created" diff --git a/tox.ini b/tox.ini index 7f15234..3081173 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,7 @@ allowlist_externals = ls rm cat + pytest {toxinidir}/dist/cli setenv = PYTHONPATH=. @@ -24,28 +25,17 @@ ignore = E722, W503 filterwarnings = ignore::DeprecationWarning [testenv:test_run] +changedir = tests commands = - rm -rf test_result - fosslight_bin -p tests -o test_result -f csv - fosslight_bin -p tests -e test commons-logging-1.2.jar -o test_result/exclude_result.csv -f csv - ls test_result/ - bash -c 'find test_result -type f -name "fosslight_report*.csv" | xargs cat' - bash -c 'find test_result -type f -name "fosslight_binary*.txt" | xargs cat' + pytest -n 4 initial_tox_test.py::test_test_run_environment [testenv:release] deps = -r{toxinidir}/requirements-dev.txt commands = - fosslight_bin -h - fosslight_bin -p tests -o test_result/result.csv -f csv - fosslight_bin -p tests -e test commons-logging-1.2.jar -o test_result/exclude_result.csv -f csv - ls test_result/ - cat test_result/result.csv - cat test_result/exclude_result.csv - fosslight_bin -p tests -o test_result/result.json -f opossum + pytest -n 5 tests/initial_tox_test.py::test_release_environment pytest -v --flake8 pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --hidden-import=pkg_resources.extern {toxinidir}/dist/cli -p tests -o test_result_cli - ; py.test --cov-report term-missing --cov={envsitepackagesdir}/fosslight_binary - \ No newline at end of file + ; py.test --cov-report term-missing --cov={envsitepackagesdir}/fosslight_binary \ No newline at end of file From ec665972bf7c3af8590573c1fb39920c0cc488a5 Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Sat, 28 Sep 2024 16:12:42 +0900 Subject: [PATCH 03/12] Update initial_tox_test.py --- tests/initial_tox_test.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/initial_tox_test.py b/tests/initial_tox_test.py index 15e21c9..727a778 100644 --- a/tests/initial_tox_test.py +++ b/tests/initial_tox_test.py @@ -1,3 +1,8 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2020 LG Electronics Inc. +# SPDX-License-Identifier: Apache-2.0 + import os import subprocess From 23e3bcdcb72e2e88528871ee1d7d826e6d98dfe0 Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Sat, 28 Sep 2024 16:44:14 +0900 Subject: [PATCH 04/12] Update initial_tox_test.py --- tests/initial_tox_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/initial_tox_test.py b/tests/initial_tox_test.py index 727a778..54335f6 100644 --- a/tests/initial_tox_test.py +++ b/tests/initial_tox_test.py @@ -8,7 +8,7 @@ def run_command(command): # 리눅스 명령어 실행 - result = subprocess.run(command, shell=True, capture_output=True, text=True) + result = subprocess.run(command, capture_output=True, text=True) success = result.returncode == 0 output = result.stdout if success else result.stderr return success, output From b3243a89bd24f68f64e277c1aac1e27a31806c3f Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:47:38 +0900 Subject: [PATCH 05/12] Update initial_tox_test.py --- tests/initial_tox_test.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/initial_tox_test.py b/tests/initial_tox_test.py index 54335f6..2ffb71b 100644 --- a/tests/initial_tox_test.py +++ b/tests/initial_tox_test.py @@ -7,8 +7,8 @@ import subprocess -def run_command(command): # 리눅스 명령어 실행 - result = subprocess.run(command, capture_output=True, text=True) +def run_command(*args): # 리눅스 명령어 실행 + result = subprocess.run(args, capture_output=True, text=True) success = result.returncode == 0 output = result.stdout if success else result.stderr return success, output @@ -16,14 +16,14 @@ def run_command(command): # 리눅스 명령어 실행 def test_test_run_environment(): # 테스트 환경 tox.ini # Given - run_command("rm -rf test_result") + run_command("rm", "-rf", "test_result") os.makedirs("test_result", exist_ok=True) # When - csv_success, _ = run_command("fosslight_bin -p . -o test_result -f csv") - exclude_success, _ = run_command("fosslight_bin -p . -e test commons-logging-1.2.jar -o test_result/exclude_result.csv -f csv") - files_in_result = run_command("ls test_result/")[1].split() - txt_success, txt_output = run_command("bash -c 'find test_result -type f -name \"fosslight_log*.txt\"'") + csv_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "csv") + exclude_success, _ = run_command("fosslight_bin", "-p", ".", "-e", "test", "commons-logging-1.2.jar", "-o", "test_result/exclude_result.csv", "-f", "csv") + files_in_result = run_command("ls", "test_result")[1].split() + txt_success, txt_output = run_command("find", "test_result", "-type", "f", "-name", "fosslight_log*.txt") # Then csv_files = [f for f in files_in_result if f.endswith('.csv')] @@ -36,15 +36,15 @@ def test_test_run_environment(): # 테스트 환경 tox.ini def test_release_environment(): # 릴리즈 환경 tox.ini # Given - run_command("rm -rf test_result") + run_command("rm", "-rf", "test_result") os.makedirs("test_result", exist_ok=True) # When - help_success, _ = run_command("fosslight_bin -h") - csv_success, _ = run_command("fosslight_bin -p . -o test_result/result.csv -f csv") - exclude_csv_success, _ = run_command("fosslight_bin -p . -e test commons-logging-1.2.jar -o test_result/exclude_result.csv -f csv") - json_success, _ = run_command("fosslight_bin -p . -o test_result/result.json -f opossum") - files_in_result = run_command("ls test_result/")[1].split() + help_success, _ = run_command("fosslight_bin", "-h") + csv_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result/result.csv", "-f", "csv") + exclude_csv_success, _ = run_command("fosslight_bin", "-p", ".", "-e", "test", "commons-logging-1.2.jar", "-o", "test_result/exclude_result.csv", "-f", "csv") + json_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result/result.json", "-f", "opossum") + files_in_result = run_command("ls", "test_result")[1].split() # Then required_files = ['result.csv', 'exclude_result.csv', 'result.json'] From 040bab3bbd1eff5348fd8868f9dc3c823c0d1157 Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:09:08 +0900 Subject: [PATCH 06/12] Update initial_tox_test.py --- tests/initial_tox_test.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/initial_tox_test.py b/tests/initial_tox_test.py index 2ffb71b..fb10477 100644 --- a/tests/initial_tox_test.py +++ b/tests/initial_tox_test.py @@ -16,12 +16,19 @@ def run_command(*args): # 리눅스 명령어 실행 def test_test_run_environment(): # 테스트 환경 tox.ini # Given - run_command("rm", "-rf", "test_result") + run_command("rm", "-rf", "test_result") os.makedirs("test_result", exist_ok=True) # When csv_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "csv") - exclude_success, _ = run_command("fosslight_bin", "-p", ".", "-e", "test", "commons-logging-1.2.jar", "-o", "test_result/exclude_result.csv", "-f", "csv") + exclude_success, _ = run_command( + "fosslight_bin", + "-p", ".", + "-e", "test", "commons-logging-1.2.jar", + "-o", "test_result/exclude_result.csv", + "-f", "csv" + ) + files_in_result = run_command("ls", "test_result")[1].split() txt_success, txt_output = run_command("find", "test_result", "-type", "f", "-name", "fosslight_log*.txt") @@ -42,7 +49,14 @@ def test_release_environment(): # 릴리즈 환경 tox.ini # When help_success, _ = run_command("fosslight_bin", "-h") csv_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result/result.csv", "-f", "csv") - exclude_csv_success, _ = run_command("fosslight_bin", "-p", ".", "-e", "test", "commons-logging-1.2.jar", "-o", "test_result/exclude_result.csv", "-f", "csv") + exclude_csv_success, _ = run_command( + "fosslight_bin", + "-p", ".", + "-e", "test", "commons-logging-1.2.jar", + "-o", "test_result/exclude_result.csv", + "-f", "csv" + ) + json_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result/result.json", "-f", "opossum") files_in_result = run_command("ls", "test_result")[1].split() From 0655ac1958163971e1de93deaf83fbd7db28c745 Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:07:09 +0900 Subject: [PATCH 07/12] create new test case --- tests/file_format_test.py | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/file_format_test.py diff --git a/tests/file_format_test.py b/tests/file_format_test.py new file mode 100644 index 0000000..b370ab0 --- /dev/null +++ b/tests/file_format_test.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2020 LG Electronics Inc. +# SPDX-License-Identifier: Apache-2.0 + +import os +import subprocess + + +def run_command(*args): # 리눅스 명령어 실행 + result = subprocess.run(args, capture_output=True, text=True) + success = result.returncode == 0 + output = result.stdout if success else result.stderr + return success, output + + +def test_output_file_format(): # 테스트 환경 tox.ini + # Given + run_command("rm", "-rf", "test_result") + os.makedirs("test_result", exist_ok=True) + + # When + excel_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "excel") + csv_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "csv") + opossum_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "opossum") + yaml_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "yaml") + files_in_result = os.listdir("test_result") + + # Then + excel_files = [f for f in files_in_result if f.endswith('.xlsx')] # Assuming Excel files end with .xlsx + csv_files = [f for f in files_in_result if f.endswith('.csv')] + opossum_files = [f for f in files_in_result if f.endswith('.json')] # Assuming opossum files are in JSON format + yaml_files = [f for f in files_in_result if f.endswith('.yaml') or f.endswith('.yml')] + + assert excel_success is True, "Test Output File : Excel files not properly created (not create)" + assert len(excel_files) > 0, "Test Output File : Excel files not properly created (length)" + + assert csv_success is True, "Test Output File : CSV files not properly created (not create)" + assert len(csv_files) > 0, "Test Output File : CSV files not properly created (length)" + + assert opossum_success is True, "Test Output File : JSON files not properly created (not create)" + assert len(opossum_files) > 0, "Test Output File : JSON files not properly created (length)" + + assert yaml_success is True, "Test Output File : Yaml files not properly created (not create)" + assert len(yaml_files) > 0, "Test Output File : Yaml files not properly created (length)" From 6b964113e09dbcf5dd0d8a122a1ceebe35901d21 Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:07:45 +0900 Subject: [PATCH 08/12] Update tox.ini --- tox.ini | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 3081173..8449a49 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,11 @@ changedir = tests commands = pytest -n 4 initial_tox_test.py::test_test_run_environment +[testenv:format_test] +changedir = tests +commands = + pytest -n 4 file_format_test.py::test_output_file_format + [testenv:release] deps = -r{toxinidir}/requirements-dev.txt @@ -38,4 +43,4 @@ commands = pytest -v --flake8 pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --hidden-import=pkg_resources.extern {toxinidir}/dist/cli -p tests -o test_result_cli - ; py.test --cov-report term-missing --cov={envsitepackagesdir}/fosslight_binary \ No newline at end of file + ; py.test --cov-report term-missing --cov={envsitepackagesdir}/fosslight_binary From 0f904ff3a98802963788b52e0d8d967ccc61d2e4 Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Thu, 3 Oct 2024 18:04:53 +0900 Subject: [PATCH 09/12] Update file_format_test.py --- tests/file_format_test.py | 57 ++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/tests/file_format_test.py b/tests/file_format_test.py index b370ab0..d03816d 100644 --- a/tests/file_format_test.py +++ b/tests/file_format_test.py @@ -5,6 +5,21 @@ import os import subprocess +import shutil +import pytest +import tempfile + + +@pytest.fixture(scope="function", autouse=True) +def setup_test_result_dir_and_teardown(): + # 각 테스트마다 임시 디렉토리 생성 + test_result_dir = tempfile.mkdtemp(dir=".") # 고유한 임시 디렉토리 생성 + print("==============setup: {test_result_dir}==============") + + yield test_result_dir # 임시 디렉토리 경로를 테스트 함수로 넘김 + + print("==============tearDown==============") + shutil.rmtree(test_result_dir) def run_command(*args): # 리눅스 명령어 실행 @@ -14,32 +29,26 @@ def run_command(*args): # 리눅스 명령어 실행 return success, output -def test_output_file_format(): # 테스트 환경 tox.ini +@pytest.mark.parametrize("file_format, extension", [ + ("excel", ".xlsx"), + ("csv", ".csv"), + ("opossum", ".json"), + ("yaml", [".yaml", ".yml"]) +]) +def test_output_file_format(file_format, extension, setup_test_result_dir_and_teardown): # 테스트 환경 tox.ini # Given - run_command("rm", "-rf", "test_result") - os.makedirs("test_result", exist_ok=True) + test_result_dir = setup_test_result_dir_and_teardown # When - excel_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "excel") - csv_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "csv") - opossum_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "opossum") - yaml_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "yaml") - files_in_result = os.listdir("test_result") + success, _ = run_command("fosslight_bin", "-p", ".", "-o", test_result_dir, "-f", file_format) + files_in_result = os.listdir(test_result_dir) # Then - excel_files = [f for f in files_in_result if f.endswith('.xlsx')] # Assuming Excel files end with .xlsx - csv_files = [f for f in files_in_result if f.endswith('.csv')] - opossum_files = [f for f in files_in_result if f.endswith('.json')] # Assuming opossum files are in JSON format - yaml_files = [f for f in files_in_result if f.endswith('.yaml') or f.endswith('.yml')] - - assert excel_success is True, "Test Output File : Excel files not properly created (not create)" - assert len(excel_files) > 0, "Test Output File : Excel files not properly created (length)" - - assert csv_success is True, "Test Output File : CSV files not properly created (not create)" - assert len(csv_files) > 0, "Test Output File : CSV files not properly created (length)" - - assert opossum_success is True, "Test Output File : JSON files not properly created (not create)" - assert len(opossum_files) > 0, "Test Output File : JSON files not properly created (length)" - - assert yaml_success is True, "Test Output File : Yaml files not properly created (not create)" - assert len(yaml_files) > 0, "Test Output File : Yaml files not properly created (length)" + if isinstance(extension, list): + # 생성된 파일 명칭을 리스트로 갖고오는 로직 + matching_files = [f for f in files_in_result if any(f.endswith(ext) for ext in extension)] + else: + matching_files = [f for f in files_in_result if f.endswith(extension)] + + assert success is True, f"Test Output File : {file_format} files not properly created (not create)" + assert len(matching_files) > 0, f"Test Output File : {file_format} files not properly created (length)" From edfcbbf3e1a10d859189d9c1f66bd2215a46ffc8 Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Thu, 3 Oct 2024 18:05:51 +0900 Subject: [PATCH 10/12] Update initial_tox_test.py --- tests/initial_tox_test.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/initial_tox_test.py b/tests/initial_tox_test.py index fb10477..24c61c9 100644 --- a/tests/initial_tox_test.py +++ b/tests/initial_tox_test.py @@ -5,6 +5,21 @@ import os import subprocess +import shutil +import pytest + +TEST_RESULT_DIR = "test_result" # 테스트 디렉토리 명 + + +@pytest.fixture(scope="function", autouse=True) # 테스트 디렉토리 생성/삭제 로직 +def setup_test_result_dir_and_teardown(): + print("==============setup==============") + os.makedirs(TEST_RESULT_DIR, exist_ok=True) + + yield + + print("==============tearDown==============") + shutil.rmtree(TEST_RESULT_DIR) def run_command(*args): # 리눅스 명령어 실행 @@ -15,10 +30,6 @@ def run_command(*args): # 리눅스 명령어 실행 def test_test_run_environment(): # 테스트 환경 tox.ini - # Given - run_command("rm", "-rf", "test_result") - os.makedirs("test_result", exist_ok=True) - # When csv_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result", "-f", "csv") exclude_success, _ = run_command( @@ -42,10 +53,6 @@ def test_test_run_environment(): # 테스트 환경 tox.ini def test_release_environment(): # 릴리즈 환경 tox.ini - # Given - run_command("rm", "-rf", "test_result") - os.makedirs("test_result", exist_ok=True) - # When help_success, _ = run_command("fosslight_bin", "-h") csv_success, _ = run_command("fosslight_bin", "-p", ".", "-o", "test_result/result.csv", "-f", "csv") From 3af7a1d2cf59c28e2c2d6d55c49c0881058e8c04 Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Thu, 3 Oct 2024 18:06:39 +0900 Subject: [PATCH 11/12] Update tox.ini --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 8449a49..0b129b2 100644 --- a/tox.ini +++ b/tox.ini @@ -37,9 +37,8 @@ commands = [testenv:release] deps = -r{toxinidir}/requirements-dev.txt - commands = - pytest -n 5 tests/initial_tox_test.py::test_release_environment + pytest -n 4 tests/initial_tox_test.py::test_release_environment pytest -v --flake8 pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --hidden-import=pkg_resources.extern {toxinidir}/dist/cli -p tests -o test_result_cli From a9220c9654455ef0023249525a184ac1aa63adf9 Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Thu, 3 Oct 2024 19:06:02 +0900 Subject: [PATCH 12/12] Update tox.ini --- tox.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 0b129b2..1c4f0ca 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,6 @@ allowlist_externals = ls rm cat - pytest {toxinidir}/dist/cli setenv = PYTHONPATH=. @@ -25,11 +24,15 @@ ignore = E722, W503 filterwarnings = ignore::DeprecationWarning [testenv:test_run] +deps = + -r{toxinidir}/requirements-dev.txt changedir = tests commands = pytest -n 4 initial_tox_test.py::test_test_run_environment [testenv:format_test] +deps = + -r{toxinidir}/requirements-dev.txt changedir = tests commands = pytest -n 4 file_format_test.py::test_output_file_format