-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor existing tox test to pytest (#225)
Signed-off-by: yongjunhong <[email protected]>
- Loading branch information
Showing
14 changed files
with
306 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
flake8==3.9.2 | ||
pyinstaller | ||
pyinstaller>=6.10.0 | ||
tox>=4.18.1 | ||
pytest | ||
pytest-cov | ||
|
This file contains 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 |
---|---|---|
|
@@ -10,4 +10,4 @@ requirements-parser | |
defusedxml | ||
packageurl-python | ||
igraph | ||
matplotlib | ||
matplotlib |
This file contains 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,40 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import shutil | ||
import pytest | ||
|
||
set_up_directories = [ | ||
"tests/result/android", | ||
"tests/result/cocoapods", | ||
"tests/result/exclude", | ||
"tests/result/gradle", | ||
"tests/result/gradle2", | ||
"tests/result/helm", | ||
"tests/result/maven1", | ||
"tests/result/maven2", | ||
"tests/result/multi_pypi_npm", | ||
"tests/result/npm1", | ||
"tests/result/npm2", | ||
"tests/result/nuget1", | ||
"tests/result/nuget2", | ||
"tests/result/pub", | ||
"tests/result/pypi" | ||
] | ||
|
||
remove_directories = set_up_directories | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def setup_test_result_dir_and_teardown(): | ||
print("==============setup==============") | ||
for directory in set_up_directories: | ||
os.makedirs(directory, exist_ok=True) | ||
|
||
yield | ||
|
||
print("==============tearDown==============") | ||
for directory in remove_directories: | ||
shutil.rmtree(directory) |
Empty file.
This file contains 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,31 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import pytest | ||
import subprocess | ||
|
||
DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path, extra_args", [ | ||
("tests/test_android", "tests/result/android", "-m android") | ||
]) | ||
@pytest.mark.ubuntu | ||
def test_ubuntu(input_path, output_path, extra_args): | ||
command = f"fosslight_dependency -p {input_path} -o {output_path} {extra_args}" | ||
result = subprocess.run(command, shell=True, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path", [ | ||
(os.path.join("tests", "test_android", "sunflower"), os.path.join("tests", "result", "android")) | ||
]) | ||
@pytest.mark.windows | ||
def test_windows(input_path, output_path): | ||
command = f"{DIST_PATH} -p {input_path} -o {output_path}" | ||
result = subprocess.run(command, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" |
This file contains 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,18 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import pytest | ||
import subprocess | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path, extra_args", [ | ||
("tests/test_cocoapods", "tests/result/cocoapods", "-m cocoapods") | ||
]) | ||
@pytest.mark.ubuntu | ||
def test_ubuntu(input_path, output_path, extra_args): | ||
command = f"fosslight_dependency -p {input_path} -o {output_path} {extra_args}" | ||
result = subprocess.run(command, shell=True, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" |
This file contains 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,33 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import pytest | ||
import subprocess | ||
|
||
DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path", [ | ||
("tests/test_gradle/jib", "tests/result/gradle"), | ||
("tests/test_gradle2", "tests/result/gradle2") | ||
]) | ||
@pytest.mark.ubuntu | ||
def test_ubuntu(input_path, output_path): | ||
command = f"fosslight_dependency -p {input_path} -o {output_path}" | ||
result = subprocess.run(command, shell=True, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path", [ | ||
(os.path.join("tests", "test_gradle", "jib"), os.path.join("tests", "result", "gradle")), | ||
(os.path.join("tests", "test_gradle2"), os.path.join("tests", "result", "gradle2")) | ||
]) | ||
@pytest.mark.windows | ||
def test_windows(input_path, output_path): | ||
command = f"{DIST_PATH} -p {input_path} -o {output_path} -m gradle" | ||
result = subprocess.run(command, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" |
This file contains 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,18 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import pytest | ||
import subprocess | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path, extra_args", [ | ||
("tests/test_helm", "tests/result/helm", "-m helm") | ||
]) | ||
@pytest.mark.ubuntu | ||
def test_ubuntu(input_path, output_path, extra_args): | ||
command = f"fosslight_dependency -p {input_path} -o {output_path} {extra_args}" | ||
result = subprocess.run(command, shell=True, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" |
This file contains 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,32 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import pytest | ||
import subprocess | ||
|
||
DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path", [ | ||
("tests/test_maven1/lombok.maven", "tests/result/maven1"), | ||
("tests/test_maven2", "tests/result/maven2") | ||
]) | ||
@pytest.mark.ubuntu | ||
def test_ubuntu(input_path, output_path): | ||
command = f"fosslight_dependency -p {input_path} -o {output_path}" | ||
result = subprocess.run(command, shell=True, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path", [ | ||
(os.path.join("tests", "test_maven2"), os.path.join("tests", "result", "maven2")) | ||
]) | ||
@pytest.mark.windows | ||
def test_windows(input_path, output_path): | ||
command = f"{DIST_PATH} -p {input_path} -o {output_path} -m maven" | ||
result = subprocess.run(command, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" |
This file contains 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,19 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import pytest | ||
import subprocess | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path, extra_args", [ | ||
("tests/test_npm1", "tests/result/npm1", ""), | ||
("tests/test_npm2", "tests/result/npm2", "-m npm") | ||
]) | ||
@pytest.mark.ubuntu | ||
def test_ubuntu(input_path, output_path, extra_args): | ||
command = f"fosslight_dependency -p {input_path} -o {output_path} {extra_args}" | ||
result = subprocess.run(command, shell=True, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" |
This file contains 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,38 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import pytest | ||
import subprocess | ||
|
||
UBUNTU_COMMANDS = [ | ||
"fosslight_dependency -p tests/test_nuget -o tests/result/nuget1", | ||
"fosslight_dependency -p tests/test_nuget2 -o tests/result/nuget2" | ||
] | ||
|
||
DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path", [ | ||
("tests/test_nuget", "tests/result/nuget1"), | ||
("tests/test_nuget2", "tests/result/nuget2") | ||
]) | ||
@pytest.mark.ubuntu | ||
def test_ubuntu(input_path, output_path): | ||
command = f"fosslight_dependency -p {input_path} -o {output_path}" | ||
result = subprocess.run(command, shell=True, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path", [ | ||
(os.path.join("tests", "test_nuget"), os.path.join("tests", "result", "nuget1")), | ||
(os.path.join("tests", "test_nuget2"), os.path.join("tests", "result", "nuget2")) | ||
]) | ||
@pytest.mark.windows | ||
def test_windows(input_path, output_path): | ||
command = f"{DIST_PATH} -p {input_path} -o {output_path}" | ||
result = subprocess.run(command, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" |
This file contains 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,34 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import pytest | ||
import subprocess | ||
|
||
DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path", [ | ||
("tests/test_pub", "tests/result/pub"), | ||
("tests/test_exclude -e requirements.txt", "tests/result/exclude") | ||
]) | ||
@pytest.mark.ubuntu | ||
def test_ubuntu(input_path, output_path): | ||
command = f"fosslight_dependency -p {input_path} -o {output_path}" | ||
result = subprocess.run(command, shell=True, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path, extra_args", [ | ||
(os.path.join("tests", "test_pub"), os.path.join("tests", "result", "pub"), ""), | ||
(os.path.join("tests", "test_pub"), os.path.join("tests", "result", "pub"), "-f opossum"), | ||
(os.path.join("tests", "test_exclude") + " -e requirements.txt", os.path.join("tests", "result", "exclude"), "") | ||
]) | ||
@pytest.mark.windows | ||
def test_windows(input_path, output_path, extra_args): | ||
command = f"{DIST_PATH} -p {input_path} -o {output_path} {extra_args}" | ||
result = subprocess.run(command, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" |
This file contains 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,33 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021 LG Electronics Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import pytest | ||
import subprocess | ||
|
||
DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path, extra_args", [ | ||
("tests/test_pypi", "tests/result/pypi", ""), | ||
("tests/test_multi_pypi_npm", "tests/result/multi_pypi_npm", ""), | ||
("tests/test_multi_pypi_npm", "tests/result/multi_pypi_npm", "-f opossum") | ||
]) | ||
@pytest.mark.ubuntu | ||
def test_ubuntu(input_path, output_path, extra_args): | ||
command = f"fosslight_dependency -p {input_path} -o {output_path} {extra_args}" | ||
result = subprocess.run(command, shell=True, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" | ||
|
||
|
||
@pytest.mark.parametrize("input_path, output_path", [ | ||
(os.path.join("tests", "test_pypi"), os.path.join("tests", "result", "pypi")) | ||
]) | ||
@pytest.mark.windows | ||
def test_windows(input_path, output_path): | ||
command = f"{DIST_PATH} -p {input_path} -o {output_path}" | ||
result = subprocess.run(command, capture_output=True, text=True) | ||
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}" |
This file contains 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