# Tests ISO Scalpel ships with a focused test suite built on `pytest`. ## Running From the project root: ```bash pip install -e '.[dev]' # pytest + ruff python -m pytest # run everything python -m pytest tests/test_deps.py -v # one module, verbose python -m pytest -k OfferToInstall # a single test class ruff check . # lint (must be clean) ``` `tests/test_deps.py` is hermetic — it mocks every third-party import and never touches the network or filesystem, so it runs anywhere pytest does. `tests/test_iso_model.py` and `tests/test_ui.py` require PySide6 and pycdlib to be importable; they self-skip with `pytest.importorskip` when either is absent (e.g. on a headless CI without the Qt runtime libs). On Linux they also need `QT_QPA_PLATFORM=offscreen` and the Qt shared libraries (`libegl1`, `libgl1`, …); install them with: ```bash sudo apt install libegl1 libgl1 libglib2.0-0 libfontconfig1 \ libdbus-1-3 libxkbcommon0 libxcb-cursor0 ``` ## What's covered | File | Subject | |-----------------------|------------------------------------------------------------------------------------------------------------------| | `tests/test_deps.py` | Dependency detection, version comparison, report formatting, install-command construction, interactive install flow (user-accept / user-decline / sudo fallback / sudo failure), `ensure_dependencies()` exit-code behaviour, `--check-deps` CLI flag parsing. | | `tests/test_iso_model.py` | `IsoTreeModel` root-handling: `rowCount(QModelIndex())` reflects `/` contents directly (no virtual placeholder row), `fetchMore` populates without recursion, `index_from_path('/')` yields the invalid model root, `refresh_parent('/')` re-fetches without crashing, and the ISO pane shows entries + breadcrumb after `refresh()`. | | `tests/test_ui.py` | Main-window UI contract: single-tab close-button hiding, two-tab restore, splitter sizes give the right pane non-zero width, transfer column structure + wiring, swap action absent from toolbar but bound to `Ctrl+Shift+X`, filter-box max widths, `Boot Image` action icon, `FsPane` column sizing. | ## Adding tests Mirror each new module under `iso_scalpel/` with a `tests/test_.py`. Use `unittest.mock.patch` for any third-party imports the module touches so the hermetic part of the suite stays runnable without PySide6 / pycdlib.