wakepy
wakepy copied to clipboard
WSL Method Implementation.
This is an initial pass to fix #36, #161. It is missing unit tests. As it calls out to PowerShell, I don't know how to best write unit tests testing the functionality.
I figured that as I try to come up with unit tests, I could get your feedback on this PR.
This could also be adapted to fix #167.
Hi @ccrutchf , thanks for the PR! Very nice work! :)
I commented on the code about few small details.
re: Unit tests
Yeah this is the same pain in all of the wakepy.Methods, as they all need to call some other software to work. I think it's enough that the automatic tests test that the external software gets the calls we expect. I've been just mocking or faking the required parts and checking that they're called in correct order and with correct arguments.
Then, in manual tests (done once per Method when creating it), I check that the mode is actually activated and it works as it should.
I just ran tox
on my machine and it passed on python 3.12 but failed on 3.7 and 3.10, most likely due to the missing enum.StrEnum. It also failed the formatting check. You may autoformat the code with isort + black. Usually that settles it.
Manual tests
I could boot to Windows to test this manually. Did you already test this on WSL?
Windows support?
I was wondering if this would actually work also on Windows? If so, this could supersede the old windows.py
(perhaps then rename to kernel32.py
or something..? This already should fix the https://github.com/fohrloop/wakepy/issues/167 as is, so it is quite attractive also in that sense. And it's nice if there's less code to be maintained :) I can also test this once I have some time.
Hi @ccrutchf , have you had time to think about unit tests? Would you still like to provide them? If not, I could take this as is, merge to dev (after a rebase), and write the unit tests :)
Hi, I removed the dev
branch to close https://github.com/fohrloop/wakepy/issues/305 (that closed this PR automatically). The changes could be merged to main
. How it would be done in practice is to sync the fork (or remove the old one and create a new one), and (1) copy the wsl.py and (2) edit the 3 other files (1+1+6 lines), or save the modifications as a patch file and apply the patch.