Skip to content

Commit 751a89d

Browse files
authored
Refactor existing tox test to pytest (#189)
Signed-off-by: MoonJeWoong <[email protected]>
1 parent b377793 commit 751a89d

31 files changed

+400
-119
lines changed

tests/__init__.py

Whitespace-only changes.

tests/conftest.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright (c) 2021 LG Electronics Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
import os
4+
import shutil
5+
6+
import pytest
7+
8+
from tests import constants
9+
from fosslight_util.constant import FOSSLIGHT_SOURCE
10+
from fosslight_util.oss_item import ScannerItem, FileItem, OssItem
11+
12+
set_up_directories = [
13+
constants.TEST_RESULT_DIR,
14+
os.path.join(constants.TEST_RESULT_DIR, "convert")
15+
]
16+
remove_directories = [constants.TEST_RESULT_DIR]
17+
18+
19+
@pytest.fixture(scope="function", autouse=True)
20+
def setup_test_result_dir_and_teardown():
21+
print("==============setup==============")
22+
for dir in set_up_directories:
23+
os.makedirs(dir, exist_ok=True)
24+
25+
yield
26+
27+
print("==============tearDown==============")
28+
for dir in remove_directories:
29+
shutil.rmtree(dir)
30+
31+
32+
@pytest.fixture
33+
def scan_item():
34+
scan_item = ScannerItem(FOSSLIGHT_SOURCE)
35+
scan_item.set_cover_pathinfo('tests/test_excel_and_csv', '')
36+
scan_item.set_cover_comment('This is a test comment')
37+
38+
file_item = FileItem('test_result/excel_and_csv')
39+
40+
oss_item = OssItem("test_name1", "1.0.0", "Apache-2.0", "https://abc.com")
41+
oss_item.comment = "test_name comment"
42+
file_item.oss_items.append(oss_item)
43+
44+
oss_item2 = OssItem("test_name2", "2.0.0", "MIT", "https://abc2.com")
45+
file_item.oss_items.append(oss_item2)
46+
47+
oss_item3 = OssItem("test_name3", "1.0.0", "GPL-2.0,BSD-3-Clause", "https://abc3.com")
48+
file_item.oss_items.append(oss_item3)
49+
file_item.comment = "all test comment"
50+
51+
scan_item.append_file_items([file_item])
52+
53+
return scan_item

tests/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2021 LG Electronics Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
TEST_RESULT_DIR = "test_result"
5+
TEST_RESOURCES_DIR = "resources"

tests/legacy/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)