Skip to content

Add unit tests for desktop platform detection in utils #40

Closed

Description

@owenthcarey

Problem

tests/test_utils.py covers _detect_ios() thoroughly, but there are no unit tests for _detect_desktop() or for the mutual exclusion between IS_ANDROID, IS_IOS, and IS_DESKTOP (see src/pythonnative/utils.py, lines 83-105 and 144).

Suggested fix

Add a test class to tests/test_utils.py, following the existing _detect_ios monkeypatch pattern, covering at least:

  • PN_PLATFORM=desktop makes _detect_desktop() return True.
  • PN_PLATFORM unset, empty, or set to another value (for example ios) makes it return False.
  • The combination logic around line 105 (_is_desktop = (not _is_android) and (not _is_ios) and _detect_desktop()): when an Android or iOS signal is present, the desktop flag stays False, so the three flags are mutually exclusive.

Verification

pytest -q tests/test_utils.py and ./scripts/check.sh pass.

Suggested commit message

test(utils): cover desktop platform detection

Activity

  1. added
    enhancement
    good first issue
    on Sep 1, 2026
  2. glenlouis8 commented on Sep 1, 2026

    @glenlouis8
    Contributor

    I'd like to take this one. Plan: add a TestDesktopDetection class to tests/test_utils.py following the existing _detect_ios monkeypatch pattern, covering: PN_PLATFORM=desktop makes _detect_desktop() return True; PN_PLATFORM unset/empty/set to another value (e.g. ios) returns False; and the mutual-exclusion logic around utils.py line 105, asserting the desktop flag stays False when an Android or iOS signal is present. Will make sure pytest -q tests/test_utils.py and ./scripts/check.sh pass.

  3. glenlouis8 commented on Sep 2, 2026

    @glenlouis8
    Contributor

    Opened #68 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementgood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions