-
Notifications
You must be signed in to change notification settings - Fork 0
Removed LSBLK dependency, fixed progress bar. (Issue #178, partially #171) #3
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
Changes from 9 commits
732856d
205d3b3
f77fd1c
dc34beb
62f15d5
5d53b8f
79817e8
cb60160
a8a066f
f6fc2a3
dbc3e64
d4f7118
09fe322
f30d249
7505cc9
8791cf1
41eff88
f227f74
2ece545
15068d3
342683c
d39ecee
9f94364
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,12 +9,12 @@ on: | |
|
|
||
| jobs: | ||
| test: | ||
| name: "Test — Python ${{ matrix.python-version }}" | ||
| name: "Run Tests (Python 3.10+)" | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14-dev"] | ||
|
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. question (testing): Reducing the Python matrix may drop coverage for supported runtimes. This change speeds up CI but drops CI coverage for 3.11 and 3.12. If we still claim support for those versions, consider keeping at least one (e.g. 3.11 or 3.12) in the matrix to help catch compatibility issues across 3.10–3.13. |
||
| python-version: ["3.10", "3.13"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
@@ -24,25 +24,12 @@ jobs: | |
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Cache pip | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip-${{ matrix.python-version }}- | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install psutil pytest packaging platformdirs | ||
|
|
||
| - name: Install package (no-deps to avoid GUI reqs) | ||
| run: pip install -e . --no-deps | ||
| pip install -r requirements-python.txt | ||
| pip install pytest | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| pytest --maxfail=1 -q \ | ||
| --ignore=src/lufus/gui \ | ||
| --ignore=src/lufus/drives/autodetect_usb.py \ | ||
| tests/ | ||
| pytest --maxfail=1 -q tests/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| from __future__ import annotations | ||
| import subprocess | ||
| import sys | ||
| import os | ||
| from pathlib import Path | ||
| from types import SimpleNamespace | ||
| from unittest.mock import MagicMock | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[1] | ||
| SRC = ROOT / "src" | ||
|
|
@@ -15,6 +16,7 @@ | |
| def test_find_usb_returns_mount_to_label_mapping(monkeypatch) -> None: | ||
| user = "testuser" | ||
| mount_path = f"/media/{user}/MY_USB" | ||
| device_node = "/dev/sdb1" | ||
|
|
||
| monkeypatch.setattr(find_usb_module.getpass, "getuser", lambda: user) | ||
| monkeypatch.setattr( | ||
|
|
@@ -35,21 +37,36 @@ def test_find_usb_returns_mount_to_label_mapping(monkeypatch) -> None: | |
| monkeypatch.setattr( | ||
| find_usb_module.psutil, | ||
| "disk_partitions", | ||
| lambda *args, **kwargs: [SimpleNamespace(mountpoint=mount_path, device="/dev/sdb1")], | ||
| ) | ||
| monkeypatch.setattr( | ||
| find_usb_module.subprocess, | ||
| "check_output", | ||
| lambda *args, **kwargs: "lufus_USB\n", | ||
| lambda *args, **kwargs: [SimpleNamespace(mountpoint=mount_path, device=device_node)], | ||
| ) | ||
|
|
||
| # Mock os.stat safely | ||
| os_stat_orig = os.stat | ||
|
|
||
| def mock_os_stat(p): | ||
| if str(p).startswith("/dev/"): | ||
| mock_stat = MagicMock() | ||
| mock_stat.st_rdev = 1234 | ||
| return mock_stat | ||
| return os_stat_orig(p) | ||
|
|
||
| monkeypatch.setattr(find_usb_module.os, "stat", mock_os_stat) | ||
|
|
||
| # Mock pyudev | ||
| mock_context = MagicMock() | ||
| mock_device = MagicMock() | ||
| mock_device.get.return_value = "lufus_USB" | ||
| monkeypatch.setattr(find_usb_module.pyudev, "Context", lambda: mock_context) | ||
| monkeypatch.setattr(find_usb_module.pyudev.Devices, "from_device_number", lambda ctx, type, num: mock_device) | ||
|
|
||
| result = find_usb_module.find_usb() | ||
|
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. suggestion (testing): Add a test covering the fallback when pyudev returns an empty label rather than raising. The current test only covers the exception path. Since the code also falls back to the directory name when 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. suggestion (testing): Add a test for pyudev returning an empty/None label (non-exceptional) to exercise the fallback path. The new test covers the exception path from |
||
| assert result == {mount_path: "lufus_USB"} | ||
|
|
||
|
|
||
| def test_find_usb_falls_back_to_dir_name_when_lsblk_fails(monkeypatch) -> None: | ||
| def test_find_usb_falls_back_to_dir_name_when_pyudev_fails(monkeypatch) -> None: | ||
| user = "testuser" | ||
| mount_path = f"/media/{user}/NO_LABEL" | ||
| device_node = "/dev/sdc1" | ||
|
|
||
| monkeypatch.setattr(find_usb_module.getpass, "getuser", lambda: user) | ||
| monkeypatch.setattr( | ||
|
|
@@ -70,13 +87,27 @@ def test_find_usb_falls_back_to_dir_name_when_lsblk_fails(monkeypatch) -> None: | |
| monkeypatch.setattr( | ||
| find_usb_module.psutil, | ||
| "disk_partitions", | ||
| lambda *args, **kwargs: [SimpleNamespace(mountpoint=mount_path, device="/dev/sdc1")], | ||
| lambda *args, **kwargs: [SimpleNamespace(mountpoint=mount_path, device=device_node)], | ||
| ) | ||
|
|
||
| def raise_lsblk_error(*args, **kwargs): | ||
| raise subprocess.CalledProcessError(returncode=1, cmd="lsblk") | ||
| # Mock os.stat safely | ||
| os_stat_orig = os.stat | ||
|
|
||
| def mock_os_stat(p): | ||
| if str(p).startswith("/dev/"): | ||
| mock_stat = MagicMock() | ||
| mock_stat.st_rdev = 5678 | ||
| return mock_stat | ||
| return os_stat_orig(p) | ||
|
|
||
| monkeypatch.setattr(find_usb_module.os, "stat", mock_os_stat) | ||
|
|
||
| monkeypatch.setattr(find_usb_module.subprocess, "check_output", raise_lsblk_error) | ||
| # Mock pyudev to fail | ||
| mock_context = MagicMock() | ||
| monkeypatch.setattr(find_usb_module.pyudev, "Context", lambda: mock_context) | ||
| monkeypatch.setattr( | ||
| find_usb_module.pyudev.Devices, "from_device_number", MagicMock(side_effect=Exception("udev fail")) | ||
| ) | ||
|
|
||
| result = find_usb_module.find_usb() | ||
| assert result == {mount_path: "NO_LABEL"} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,8 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import subprocess | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from types import SimpleNamespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from unittest.mock import MagicMock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ROOT = Path(__file__).resolve().parents[1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SRC = ROOT / "src" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -32,14 +32,25 @@ def test_get_usb_info_returns_expected_dictionary(monkeypatch) -> None: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lambda *args, **kwargs: [SimpleNamespace(mountpoint=mount_path, device=device_node)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def fake_check_output(cmd, text=True, timeout=5): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if cmd[-2:] == ["SIZE", device_node]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return str(16 * 1024**3) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if cmd[-2:] == ["LABEL", device_node]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "MYUSB\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise AssertionError(f"Unexpected command: {cmd}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Mock os.stat safely | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| os_stat_orig = get_usb_info_module.os.stat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| monkeypatch.setattr(get_usb_info_module.subprocess, "check_output", fake_check_output) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def mock_os_stat(p): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if str(p).startswith("/dev/"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_stat = MagicMock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_stat.st_rdev = 1234 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return mock_stat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return os_stat_orig(p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| monkeypatch.setattr(get_usb_info_module.os, "stat", mock_os_stat) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Mock pyudev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_context = MagicMock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_device = MagicMock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_device.attributes = {"size": str((16 * 1024**3) // 512)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_device.get.return_value = "MYUSB" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| monkeypatch.setattr(get_usb_info_module.pyudev, "Context", lambda: mock_context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| monkeypatch.setattr(get_usb_info_module.pyudev.Devices, "from_device_number", lambda ctx, type, num: mock_device) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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. suggestion (testing): Consider adding a test for malformed or non-integer pyudev size attributes. Right now the tests only cover cases where |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = get_usb_info_module.get_usb_info(mount_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert result == { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -59,20 +70,31 @@ def test_get_usb_info_uses_mount_basename_when_label_is_empty(monkeypatch) -> No | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lambda *args, **kwargs: [SimpleNamespace(mountpoint=mount_path, device=device_node)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def fake_check_output(cmd, text=True, timeout=5): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if cmd[-2:] == ["SIZE", device_node]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return str(8 * 1024**3) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if cmd[-2:] == ["LABEL", device_node]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise AssertionError(f"Unexpected command: {cmd}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Mock os.stat safely | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| os_stat_orig = get_usb_info_module.os.stat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def mock_os_stat(p): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if str(p).startswith("/dev/"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_stat = MagicMock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_stat.st_rdev = 5678 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return mock_stat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return os_stat_orig(p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| monkeypatch.setattr(get_usb_info_module.subprocess, "check_output", fake_check_output) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| monkeypatch.setattr(get_usb_info_module.os, "stat", mock_os_stat) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Mock pyudev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_context = MagicMock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_device = MagicMock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_device.attributes = {"size": str((8 * 1024**3) // 512)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mock_device.get.return_value = None | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| monkeypatch.setattr(get_usb_info_module.pyudev, "Context", lambda: mock_context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| monkeypatch.setattr(get_usb_info_module.pyudev.Devices, "from_device_number", lambda ctx, type, num: mock_device) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = get_usb_info_module.get_usb_info(mount_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert result["label"] == "NO_LABEL" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_get_usb_info_returns_empty_when_lsblk_fails(monkeypatch) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_get_usb_info_returns_empty_when_pyudev_fails(monkeypatch) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
103
to
+107
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. suggestion (testing): Add a dedicated test for PermissionError in get_usb_info to ensure that branch is covered. Right now only the generic exception path from
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mount_path = "/media/testuser/USB" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| device_node = "/dev/sdb1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+107
to
111
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. suggestion (testing): Add a test where pyudev fails independently of os.stat to fully exercise the new error-handling path. The existing Suggested implementation: def test_get_usb_info_returns_empty_when_pyudev_fails(monkeypatch) -> None:Please add a new test function to cover the case where def test_get_usb_info_returns_empty_when_pyudev_device_lookup_raises(monkeypatch) -> None:
mount_path = "/media/testuser/USB"
device_node = "/dev/sdb1"
# Partition for the mount path is found
monkeypatch.setattr(
get_usb_info_module.psutil,
"disk_partitions",
lambda *args, **kwargs: [
SimpleNamespace(mountpoint=mount_path, device=device_node)
],
)
# os.stat succeeds and yields a valid st_dev
monkeypatch.setattr(
get_usb_info_module.os,
"stat",
lambda p: SimpleNamespace(st_dev=1234),
)
# pyudev context can be constructed, but the device lookup itself fails
mock_context = object()
monkeypatch.setattr(
get_usb_info_module.pyudev,
"Context",
lambda: mock_context,
)
def failing_from_device_number(*args, **kwargs):
raise RuntimeError("pyudev failure")
monkeypatch.setattr(
get_usb_info_module.pyudev.Devices,
"from_device_number",
failing_from_device_number,
)
result = get_usb_info_module.get_usb_info(mount_path)
# When pyudev fails independently of os.stat, we should still return an empty result
assert result is NoneIf your implementation also has a separate failure path when the device is found but def test_get_usb_info_returns_empty_when_pyudev_missing_size_attribute(monkeypatch) -> None:
mount_path = "/media/testuser/USB"
device_node = "/dev/sdb1"
monkeypatch.setattr(
get_usb_info_module.psutil,
"disk_partitions",
lambda *args, **kwargs: [
SimpleNamespace(mountpoint=mount_path, device=device_node)
],
)
monkeypatch.setattr(
get_usb_info_module.os,
"stat",
lambda p: SimpleNamespace(st_dev=1234),
)
mock_context = object()
monkeypatch.setattr(
get_usb_info_module.pyudev,
"Context",
lambda: mock_context,
)
mock_device = SimpleNamespace()
# Simulate missing / inaccessible size attribute
mock_device.attributes = {}
monkeypatch.setattr(
get_usb_info_module.pyudev.Devices,
"from_device_number",
lambda *args, **kwargs: mock_device,
)
result = get_usb_info_module.get_usb_info(mount_path)
assert result is NoneAdjust the final assertions (
Comment on lines
+107
to
111
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. suggestion (testing): Add tests for PermissionError and malformed pyudev size to fully cover get_usb_info error handling. This currently only exercises the generic
These will ensure the dedicated |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -82,9 +104,15 @@ def test_get_usb_info_returns_empty_when_lsblk_fails(monkeypatch) -> None: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lambda *args, **kwargs: [SimpleNamespace(mountpoint=mount_path, device=device_node)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def raise_lsblk_error(*args, **kwargs): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise subprocess.CalledProcessError(returncode=1, cmd="lsblk") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Mock os.stat safely | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| os_stat_orig = get_usb_info_module.os.stat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def mock_os_stat(p): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if str(p).startswith("/dev/"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise Exception("stat fail") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return os_stat_orig(p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| monkeypatch.setattr(get_usb_info_module.subprocess, "check_output", raise_lsblk_error) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| monkeypatch.setattr(get_usb_info_module.os, "stat", mock_os_stat) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This should return None because of the catch-all Exception in get_usb_info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert get_usb_info_module.get_usb_info(mount_path) is None | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
suggestion: Job name no longer differentiates between Python versions in the matrix
The static name makes all matrix jobs look identical in the Actions UI, which makes it harder to see which Python version failed. Please reintroduce the version in the job name (e.g.,
Run Tests (Python ${{ matrix.python-version }})) so each matrix entry is distinguishable.