FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnative/tests/test_utils.py at feat/dev-pythonnative-go · Zer0codestuff/pythonnative · GitHub
Zer0codestuff
pythonnative
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnative
/
tests
/
test_utils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (55 loc) · 2.8 KB
Breadcrumbs
pythonnative
/
tests
/
test_utils.py
Copy path
File metadata and controls
70 lines (55 loc) · 2.8 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""Tests for pythonnative.utils platform detection."""
import
os
import
sys
import
pytest
from
pythonnative
.
utils
import
IS_ANDROID
,
IS_IOS
,
_detect_ios
class
TestIosDetection
:
"""``_detect_ios()`` should key off explicit signals only, not on the
presence of optional packages like ``rubicon-objc``.
"""
def
test_detects_via_pn_platform_env
(
self
,
monkeypatch
:
pytest
.
MonkeyPatch
)
->
None
:
monkeypatch
.
setenv
(
"PN_PLATFORM"
,
"ios"
)
assert
_detect_ios
()
is
True
def
test_other_pn_platform_values_ignored
(
self
,
monkeypatch
:
pytest
.
MonkeyPatch
)
->
None
:
monkeypatch
.
setenv
(
"PN_PLATFORM"
,
"desktop"
)
monkeypatch
.
delenv
(
"HOME"
,
raising
=
False
)
monkeypatch
.
setattr
(
sys
,
"platform"
,
"darwin"
)
assert
_detect_ios
()
is
False
def
test_detects_via_sys_platform_ios
(
self
,
monkeypatch
:
pytest
.
MonkeyPatch
)
->
None
:
monkeypatch
.
delenv
(
"PN_PLATFORM"
,
raising
=
False
)
monkeypatch
.
setattr
(
sys
,
"platform"
,
"ios"
)
assert
_detect_ios
()
is
True
def
test_detects_via_core_simulator_home
(
self
,
monkeypatch
:
pytest
.
MonkeyPatch
)
->
None
:
monkeypatch
.
delenv
(
"PN_PLATFORM"
,
raising
=
False
)
monkeypatch
.
setattr
(
sys
,
"platform"
,
"darwin"
)
monkeypatch
.
setenv
(
"HOME"
,
"/Users/x/Library/Developer/CoreSimulator/Devices/ABCD/data"
,
)
assert
_detect_ios
()
is
True
def
test_plain_macos_is_not_ios
(
self
,
monkeypatch
:
pytest
.
MonkeyPatch
)
->
None
:
monkeypatch
.
delenv
(
"PN_PLATFORM"
,
raising
=
False
)
monkeypatch
.
setattr
(
sys
,
"platform"
,
"darwin"
)
monkeypatch
.
setenv
(
"HOME"
,
"/Users/owen"
)
assert
_detect_ios
()
is
False
def
test_plain_linux_is_not_ios
(
self
,
monkeypatch
:
pytest
.
MonkeyPatch
)
->
None
:
monkeypatch
.
delenv
(
"PN_PLATFORM"
,
raising
=
False
)
monkeypatch
.
setattr
(
sys
,
"platform"
,
"linux"
)
monkeypatch
.
setenv
(
"HOME"
,
"/home/runner"
)
assert
_detect_ios
()
is
False
class
TestPlatformFlagsConsistency
:
def
test_both_flags_are_bools
(
self
)
->
None
:
assert
isinstance
(
IS_ANDROID
,
bool
)
assert
isinstance
(
IS_IOS
,
bool
)
def
test_flags_are_mutually_exclusive
(
self
)
->
None
:
# A single Python process is never simultaneously Android and iOS.
assert
not
(
IS_ANDROID
and
IS_IOS
)
def
test_ci_environment_is_neither
(
self
)
->
None
:
"""The test suite runs on Linux/macOS hosts, so both flags are False."""
# This is more of a smoke check of the import-time detection: if
# this ever starts being True on CI, someone has accidentally made
# platform detection overeager on non-device hosts.
if
os
.
environ
.
get
(
"PN_PLATFORM"
)
==
"ios"
:
pytest
.
skip
(
"Running under PN_PLATFORM=ios; flags correctly reflect that."
)
assert
IS_ANDROID
is
False
assert
IS_IOS
is
False
Back
|
FazBrowse Home
|
New Git URL