Skip to content

Mock check_winpe in test_driver_wim and correct its call expectations. - #803

Open
MohammedAlkindi wants to merge 1 commit into
google:masterfrom
MohammedAlkindi:fix/drivers-test-host-dependent-winpe
Open

Mock check_winpe in test_driver_wim and correct its call expectations.#803
MohammedAlkindi wants to merge 1 commit into
google:masterfrom
MohammedAlkindi:fix/drivers-test-host-dependent-winpe

Conversation

@MohammedAlkindi

Copy link
Copy Markdown

test_driver_wim does not mock winpe.check_winpe(), so it reads the host registry and its outcome depends on the machine running it. On a non-WinPE host it fails.

The expected call list is also internally inconsistent: it pairs WINPE_DISM for mount and unmount with SYS_PNPUTIL for add-driver. _ProcessWim derives both from the same lru_cache-wrapped check_winpe(), so a run emits all-WinPE or all-SYS paths, never a mix.

This adds the mock returning False and corrects the two mount and unmount constants. test_driver_wim_winpe already covers the True branch with the same convention, so the two tests now cover one branch each.

python_tests.yml runs ubuntu-latest only, where os.path.join(ROOT, os.sep, ...) in constants.py discards the drive letter and WINPE_DISM equals SYS_DISM, which hides the inconsistency. That collapse is #796 and is not touched here.

Windows 11, Python 3.13.13, python -m glazier.lib.actions.drivers_test: before Ran 10 tests / FAILED (failures=1), after Ran 10 tests / OK. Inverting the mock to True makes it fail again, so it still discriminates on the branch. No other module in the suite changes status.

The test read the real registry, so its branch depended on the host. Its
expectations also mixed WINPE_DISM for mount and unmount with SYS_PNPUTIL for
add-driver, which _ProcessWim cannot emit in one run because both derive from
the same lru_cache-wrapped check_winpe result.

Mocks the probe to False and matches the mount and unmount constants to it.
test_driver_wim_winpe already covers the True branch the same way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant