FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnative/tests/test_platform.py at refs/heads/main · pythonnative/pythonnative · GitHub
pythonnative
pythonnative
Repository navigation
Code
Issues
11
(11)
Pull requests
5
(5)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnative
/
tests
/
test_platform.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
84 lines (60 loc) · 2.69 KB
Breadcrumbs
pythonnative
/
tests
/
test_platform.py
Copy path
File metadata and controls
84 lines (60 loc) · 2.69 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""Unit tests for the Platform module."""
from
__future__
import
annotations
from
typing
import
Generator
import
pytest
import
pythonnative
as
pn
from
pythonnative
.
platform
import
Platform
,
_set_platform_for_test
,
get_platform
@
pytest
.
fixture
(
autouse
=
True
)
def
_reset_platform
()
->
Generator
[
None
,
None
,
None
]:
"""Reset Platform after each test so suite order doesn't matter."""
yield
_set_platform_for_test
(
None
)
def
test_default_platform_is_test
()
->
None
:
assert
Platform
.
OS
==
"test"
assert
Platform
.
is_test
is
True
assert
Platform
.
is_ios
is
False
assert
Platform
.
is_android
is
False
def
test_get_platform_matches_os
()
->
None
:
assert
get_platform
()
==
Platform
.
OS
def
test_get_platform_exported_from_package
()
->
None
:
assert
pn
.
get_platform
()
==
pn
.
Platform
.
OS
def
test_supports_uses_platform_and_member_contracts
()
->
None
:
_set_platform_for_test
(
"ios"
)
assert
Platform
.
supports
(
"Text"
,
"font_size"
)
assert
Platform
.
supports
(
"Notifications"
,
"get_device_token"
)
assert
Platform
.
supports
(
"Text"
,
"accessibility_live_region"
)
assert
not
Platform
.
supports
(
"UninstalledExtension"
)
assert
not
Platform
.
supports
(
"Text"
,
"imaginary_property"
)
_set_platform_for_test
(
"android"
)
assert
not
Platform
.
supports
(
"Notifications"
,
"get_device_token"
)
assert
Platform
.
supports
(
"Text"
,
"accessibility_live_region"
)
_set_platform_for_test
(
"web"
)
assert
Platform
.
supports
(
"Text"
,
"font_size"
)
_set_platform_for_test
(
"test"
)
assert
not
Platform
.
supports
(
"Text"
)
def
test_version_string_present
()
->
None
:
assert
isinstance
(
Platform
.
Version
,
str
)
assert
len
(
Platform
.
Version
)
>
0
def
test_select_picks_current_platform
()
->
None
:
_set_platform_for_test
(
"ios"
)
assert
Platform
.
select
({
"ios"
:
"A"
,
"android"
:
"B"
})
==
"A"
_set_platform_for_test
(
"android"
)
assert
Platform
.
select
({
"ios"
:
"A"
,
"android"
:
"B"
})
==
"B"
def
test_select_falls_back_to_native
()
->
None
:
_set_platform_for_test
(
"ios"
)
assert
Platform
.
select
({
"native"
:
"X"
,
"default"
:
"Y"
})
==
"X"
_set_platform_for_test
(
"test"
)
# 'test' doesn't match 'native', so falls back to 'default'.
assert
Platform
.
select
({
"native"
:
"X"
,
"default"
:
"Y"
})
==
"Y"
def
test_select_default_then_explicit
()
->
None
:
_set_platform_for_test
(
"test"
)
assert
Platform
.
select
({
"default"
:
"D"
})
==
"D"
assert
Platform
.
select
({},
default
=
"E"
)
==
"E"
assert
Platform
.
select
({})
is
None
def
test_set_platform_for_test_toggles_flags
()
->
None
:
_set_platform_for_test
(
"ios"
)
assert
Platform
.
is_ios
is
True
assert
Platform
.
is_android
is
False
_set_platform_for_test
(
"android"
)
assert
Platform
.
is_ios
is
False
assert
Platform
.
is_android
is
True
Back
|
FazBrowse Home
|
New Git URL