-
Notifications
You must be signed in to change notification settings - Fork 14
Tox to pytest #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Tox to pytest #188
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
75d3b19
test_tox.py 추가
hkkim2021 b92ff6a
test_tox.py 추가
hkkim2021 17f67d0
second
hkkim2021 9ff2592
second
hkkim2021 21c3d23
flake8
hkkim2021 1c14b32
3
hkkim2021 7defdb8
4
hkkim2021 63f3b45
pytest parallel processing
hkkim2021 eb63f38
re
hkkim2021 ab84be9
add pytest-xdist
hkkim2021 926703d
re
hkkim2021 9ce06de
dev problem
hkkim2021 08f85ea
combine release testenv
hkkim2021 520d094
combine release testenv
hkkim2021 96eb048
combine release testenv
hkkim2021 91c67b9
combine release testenv
hkkim2021 ce3bee3
final
hkkim2021 69364b0
revise
hkkim2021 62e12be
revise
hkkim2021 5e2105a
revise
hkkim2021 90eeda5
setup revise
hkkim2021 529d5ed
setup revise
hkkim2021 45ee5d0
setup revise
hkkim2021 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| #!/usr/bin/env python | ||
| # -*- coding: utf-8 -*- | ||
| # Copyright (c) 2020 LG Electronics Inc. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| import os | ||
| import subprocess | ||
| import pytest | ||
| import shutil | ||
|
|
||
| remove_directories = ["test_scan", "test_scan2", "test_scan3"] | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module", autouse=True) | ||
| def setup_test_result_dir(): | ||
| print("==============setup==============") | ||
| for dir in remove_directories: | ||
| if os.path.exists(dir): | ||
| shutil.rmtree(dir) | ||
|
|
||
| yield | ||
|
|
||
|
|
||
| def run_command(command): | ||
| process = subprocess.run(command, shell=True, capture_output=True, text=True) | ||
| success = (process.returncode == 0) | ||
| return success, process.stdout if success else process.stderr | ||
|
|
||
|
|
||
| def test_run(): | ||
| scan_success, _ = run_command("fosslight_source -p tests/test_files -j -m -o test_scan") | ||
| scan_exclude_success, _ = run_command("fosslight_source -p tests -e test_files/test cli_test.py -j -m -o test_scan2") | ||
| scan_files = os.listdir("test_scan") | ||
| scan2_files = os.listdir('test_scan2') | ||
|
|
||
| assert scan_success is True, "Test Run: Scan command failed" | ||
| assert scan_exclude_success is True, "Test Run: Exclude command failed" | ||
| assert len(scan_files) > 0, "Test Run: No scan files created in test_scan directory" | ||
| assert len(scan2_files) > 0, "Test Run: No scan files created in test_scan2 directory" | ||
|
|
||
|
|
||
| def test_help_command(): | ||
| success, _ = run_command("fosslight_source -h") | ||
| assert success is True, "Test Release: Help command failed " | ||
|
|
||
|
|
||
| def test_scan_command(): | ||
| success, _ = run_command("fosslight_source -p tests/test_files -o test_scan/scan_result.csv") | ||
| assert success is True, "Test Release: Failed to generate scan result CSV file" | ||
|
|
||
| assert os.path.exists("test_scan/scan_result.csv"), "Test Release: scan_result.csv file not generated" | ||
|
|
||
| with open("test_scan/scan_result.csv", 'r') as file: | ||
| content = file.read() | ||
|
|
||
| assert len(content) > 0, "Test Release: scan_result.csv is empty" | ||
| print(f"Content of scan_result.csv:\n{content}") | ||
|
|
||
|
|
||
| def test_exclude_command(): | ||
| success, _ = run_command( | ||
| "fosslight_source -p tests -e test_files/test cli_test.py -j -m -o test_scan2/scan_exclude_result.csv" | ||
| ) | ||
| assert success is True, "Test release: Exclude scan failded" | ||
|
|
||
| assert os.path.exists("test_scan2/scan_exclude_result.csv"), "Test Release: scan_exclude_result.csv file not generated" | ||
|
|
||
| with open("test_scan2/scan_exclude_result.csv", 'r') as file: | ||
| content = file.read() | ||
|
|
||
| assert len(content) > 0, "Test Release: scan_exclude_result.csv is empty" | ||
| print(f"Content of scan_exclude_result.csv:\n{content}") | ||
|
|
||
|
|
||
| def test_json_command(): | ||
| success, _ = run_command("fosslight_source -p tests/test_files -m -j -o test_scan3/") | ||
| assert success is True, "Test release: Failed to generate JSON files" | ||
|
|
||
|
|
||
| def test_ls_test_scan3_command(): | ||
| files_in_test_scan3 = os.listdir("test_scan3") | ||
| assert len(files_in_test_scan3) > 0, "Test Release: test_scan3 is empty" | ||
| print(f"Files in test_scan3: {files_in_test_scan3}") | ||
|
|
||
|
|
||
| def test_flake8(): | ||
| success, _ = run_command("flake8 -j 4") | ||
hkkim2021 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert success is True, "Flake8: Style check failed" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.