-
Notifications
You must be signed in to change notification settings - Fork 506
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
test: add test for mismatch package build #4785
Open
kanakOS01
wants to merge
6
commits into
intel:main
Choose a base branch
from
kanakOS01:test_mismatch_pkg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+26
−0
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0f34797
test: add test for mismatch package build
kanakOS01 e250b71
remove print() from test_mismatch_cli.py
kanakOS01 b995ce6
replace 'python' with 'sys.executable'
kanakOS01 56a22b2
Merge branch 'intel:main' into test_mismatch_pkg
kanakOS01 5270310
Merge branch 'main' into test_mismatch_pkg
terriko 06a7107
Merge branch 'main' into test_mismatch_pkg
kanakOS01 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 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 |
---|---|---|
|
@@ -24,3 +24,4 @@ types-PyYAML | |
types-requests | ||
types-setuptools | ||
types-toml | ||
build |
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,8 @@ | ||||
import shutil | ||||
import sqlite3 | ||||
import subprocess | ||||
from pathlib import Path | ||||
from test.utils import LONG_TESTS | ||||
from unittest.mock import patch | ||||
|
||||
import pytest | ||||
|
@@ -26,6 +29,14 @@ def test_db(tmpdir_factory): | |||
yield str(db_file) | ||||
|
||||
|
||||
@pytest.fixture(scope="module") | ||||
def build_cleanup(): | ||||
yield | ||||
dist_dir = Path(__file__).resolve().parent.parent / "dist" | ||||
if dist_dir.exists(): | ||||
shutil.rmtree(dist_dir) | ||||
|
||||
|
||||
def test_lookup(capsys, monkeypatch, test_db): | ||||
# Test with custom database path using the --database flag | ||||
monkeypatch.setattr( | ||||
|
@@ -93,3 +104,19 @@ def verify_db(test_db): | |||
"facebook", | ||||
) | ||||
assert expected in result | ||||
|
||||
|
||||
@pytest.mark.skipif(not LONG_TESTS(), reason="Skipping long tests") | ||||
def test_package_build(build_cleanup): | ||||
print("Building package") | ||||
build = subprocess.run(["python", "-m", "build"], check=True) | ||||
assert build.returncode == 0, "Python build failed" | ||||
|
||||
print("Install package") | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We should not have any print statements in a test file |
||||
dist_dir = Path(__file__).resolve().parent.parent / "dist" | ||||
package_path = list(dist_dir.glob("*.whl"))[0] | ||||
subprocess.run(["pip", "install", str(package_path)], check=True) | ||||
|
||||
result = subprocess.run(["mismatch", "--help"], capture_output=True, text=True) | ||||
print(result) | ||||
assert "ModuleNotFoundError: No module named 'mismatch'" not in result.stderr |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, To ensure the code runs on all systems, consider using the path to the Python executable, which can be accessed via
sys.executable
andimport sys
. Other than this it looks good!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't know about this. thanks.