21
21
NDK_DOWNLOAD_URL ,
22
22
ARMEABI_MAX_TARGET_API ,
23
23
MIN_TARGET_API ,
24
+ UNKNOWN_NDK_MESSAGE ,
25
+ PARSE_ERROR_NDK_MESSAGE ,
26
+ READ_ERROR_NDK_MESSAGE ,
27
+ ENSURE_RIGHT_NDK_MESSAGE ,
28
+ NDK_LOWER_THAN_SUPPORTED_MESSAGE ,
29
+ UNSUPPORTED_NDK_API_FOR_ARMEABI_MESSAGE ,
30
+ CURRENT_NDK_VERSION_MESSAGE ,
31
+ RECOMMENDED_NDK_VERSION_MESSAGE ,
32
+ TARGET_NDK_API_GREATER_THAN_TARGET_API_MESSAGE ,
33
+ OLD_NDK_API_MESSAGE ,
34
+ NEW_NDK_MESSAGE ,
35
+ OLD_API_MESSAGE ,
24
36
)
25
37
from pythonforandroid .util import BuildInterruptingException
38
+
26
39
running_in_py2 = int (py_version [0 ]) < 3
27
40
28
41
@@ -45,15 +58,17 @@ def test_check_ndk_version_greater_than_recommended(self, mock_read_ndk):
45
58
self .assertEqual (
46
59
cm .output ,
47
60
[
48
- "INFO:p4a:[INFO]: Found NDK version {ndk_current}" .format (
49
- ndk_current = MAX_NDK_VERSION + 1
61
+ "INFO:p4a:[INFO]: {}" .format (
62
+ CURRENT_NDK_VERSION_MESSAGE .format (
63
+ ndk_version = MAX_NDK_VERSION + 1
64
+ )
50
65
),
51
- "WARNING:p4a:[WARNING]:"
52
- " Maximum recommended NDK version is {ndk_recommended}" .format (
53
- ndk_recommended = RECOMMENDED_NDK_VERSION
66
+ "WARNING:p4a:[WARNING]: {}" .format (
67
+ RECOMMENDED_NDK_VERSION_MESSAGE .format (
68
+ recommended_ndk_version = RECOMMENDED_NDK_VERSION
69
+ )
54
70
),
55
- "WARNING:p4a:[WARNING]:"
56
- " Newer NDKs may not be fully supported by p4a." ,
71
+ "WARNING:p4a:[WARNING]: {}" .format (NEW_NDK_MESSAGE ),
57
72
],
58
73
)
59
74
@@ -64,9 +79,8 @@ def test_check_ndk_version_lower_than_recommended(self, mock_read_ndk):
64
79
check_ndk_version (self .ndk_dir )
65
80
self .assertEqual (
66
81
e .exception .args [0 ],
67
- "Unsupported NDK version detected {ndk_current}"
68
- "\n * Note: Minimum supported NDK version is {ndk_min}" .format (
69
- ndk_current = MIN_NDK_VERSION - 1 , ndk_min = MIN_NDK_VERSION
82
+ NDK_LOWER_THAN_SUPPORTED_MESSAGE .format (
83
+ min_supported = MIN_NDK_VERSION , ndk_url = NDK_DOWNLOAD_URL
70
84
),
71
85
)
72
86
mock_read_ndk .assert_called_once_with (self .ndk_dir )
@@ -83,16 +97,17 @@ def test_check_ndk_version_error(self):
83
97
self .assertEqual (
84
98
cm .output ,
85
99
[
86
- "INFO:p4a:[INFO]: Could not determine NDK version, "
87
- "no source.properties in the NDK dir" ,
88
- "WARNING:p4a:[WARNING]: Unable to read the ndk version, "
89
- "assuming that you are using an NDK greater than 17 (the "
90
- "minimum ndk required to use p4a successfully).\n "
91
- "Note: If you got build errors, consider to download the "
92
- "recommended ndk version which is 17c and try it again (after "
93
- "removing all the files generated with this build). To "
94
- "download the android NDK visit the following "
95
- "page: {download_url}" .format (download_url = NDK_DOWNLOAD_URL ),
100
+ "INFO:p4a:[INFO]: {}" .format (UNKNOWN_NDK_MESSAGE ),
101
+ "WARNING:p4a:[WARNING]: {}" .format (
102
+ READ_ERROR_NDK_MESSAGE .format (ndk_dir = self .ndk_dir )
103
+ ),
104
+ "WARNING:p4a:[WARNING]: {}" .format (
105
+ ENSURE_RIGHT_NDK_MESSAGE .format (
106
+ min_supported = MIN_NDK_VERSION ,
107
+ rec_version = RECOMMENDED_NDK_VERSION ,
108
+ ndk_url = NDK_DOWNLOAD_URL ,
109
+ )
110
+ ),
96
111
],
97
112
)
98
113
@@ -119,10 +134,7 @@ def test_read_ndk_version_error(self, mock_open_src_prop):
119
134
version = read_ndk_version (self .ndk_dir )
120
135
self .assertEqual (
121
136
cm .output ,
122
- [
123
- "INFO:p4a:[INFO]: Could not parse "
124
- "$NDK_DIR/source.properties, not checking NDK version"
125
- ],
137
+ ["INFO:p4a:[INFO]: {}" .format (PARSE_ERROR_NDK_MESSAGE )],
126
138
)
127
139
mock_open_src_prop .assert_called_once_with (
128
140
join (self .ndk_dir , "source.properties" )
@@ -135,10 +147,9 @@ def test_check_target_api_error_arch_armeabi(self):
135
147
check_target_api (RECOMMENDED_TARGET_API , "armeabi" )
136
148
self .assertEqual (
137
149
e .exception .args [0 ],
138
- "Asked to build for armeabi architecture with API {ndk_api}, but "
139
- "API {max_target_api} or greater does not support armeabi" .format (
140
- ndk_api = RECOMMENDED_TARGET_API ,
141
- max_target_api = ARMEABI_MAX_TARGET_API ,
150
+ UNSUPPORTED_NDK_API_FOR_ARMEABI_MESSAGE .format (
151
+ req_ndk_api = RECOMMENDED_TARGET_API ,
152
+ max_ndk_api = ARMEABI_MAX_TARGET_API ,
142
153
),
143
154
)
144
155
@@ -151,10 +162,9 @@ def test_check_target_api_warning_target_api(self):
151
162
cm .output ,
152
163
[
153
164
"WARNING:p4a:[WARNING]: Target API 25 < 26" ,
154
- "WARNING:p4a:[WARNING]: Target APIs lower than 26 are no "
155
- "longer supported on Google Play, and are not recommended. "
156
- "Note that the Target API can be higher than your device "
157
- "Android version, and should usually be as high as possible." ,
165
+ "WARNING:p4a:[WARNING]: {old_api_msg}" .format (
166
+ old_api_msg = OLD_API_MESSAGE
167
+ ),
158
168
],
159
169
)
160
170
@@ -169,8 +179,7 @@ def test_check_ndk_api_error_android_api(self):
169
179
check_ndk_api (ndk_api , android_api )
170
180
self .assertEqual (
171
181
e .exception .args [0 ],
172
- "Target NDK API is {ndk_api}, higher than the target Android "
173
- "API {android_api}." .format (
182
+ TARGET_NDK_API_GREATER_THAN_TARGET_API_MESSAGE .format (
174
183
ndk_api = ndk_api , android_api = android_api
175
184
),
176
185
)
@@ -187,5 +196,9 @@ def test_check_ndk_api_warning_old_ndk(self):
187
196
check_ndk_api (ndk_api , android_api )
188
197
self .assertEqual (
189
198
cm .output ,
190
- ["WARNING:p4a:[WARNING]: NDK API less than 21 is not supported" ],
199
+ [
200
+ "WARNING:p4a:[WARNING]: {}" .format (
201
+ OLD_NDK_API_MESSAGE .format (MIN_NDK_API )
202
+ )
203
+ ],
191
204
)
0 commit comments