Repository navigation
test(utils): cover desktop platform detection - #68
Merged
owenthcarey merged 2 commits intoSep 8, 2026
Merged
Conversation
Merge current main and preserve the contributed platform precedence coverage. Use the web preview detection API introduced in pythonnative#74 and verify that the retired desktop override is ignored.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
_detect_desktop()and for the mutual exclusion betweenIS_ANDROID,IS_IOSandIS_DESKTOP.Why
tests/test_utils.pycovered_detect_ios()thoroughly but nothing exercised the desktop backend or the precedence logic atutils.py:105, so a regression there would have gone unnoticed. That logic is what keeps a component from falling through every platform branch duringpn preview(the confusion described in FAQ on platform-specific code omits the browser preview (IS_WEB) #59).How (brief)
TestDesktopDetectionfollows the existing_detect_iosmonkeypatch pattern:PN_PLATFORM=desktopreturns True; unset, empty, another value, or a bare host platform returns False.TestPlatformFlagPrecedencecovers_is_desktop = (not _is_android) and (not _is_ios) and _detect_desktop(). A_redetect()helper clears the cached_is_*globals and swaps in forced detectors, since all three flags are computed once at import time and there is no public seam to re-run detection through.monkeypatchrestores both the caches and the real detectors at teardown. A parametrized sweep over all eight signal combinations asserts at most one flag is ever True.TestPlatformFlagsConsistencywidened from two flags to three, including thePN_PLATFORMskip guard so the suite still passes when run underpn preview.Testing
pytest -q tests/test_utils.pypasses (27 tests, up from 9);./scripts/check.shpasses.Risks/Impact
Docs/Follow-ups
"desktop"OS value andis_desktop#39 and FAQ on platform-specific code omits the browser preview (IS_WEB) #59.Closes #40