2121 NDK_DOWNLOAD_URL ,
2222 ARMEABI_MAX_TARGET_API ,
2323 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 ,
2436)
2537from pythonforandroid .util import BuildInterruptingException
38+
2639running_in_py2 = int (py_version [0 ]) < 3
2740
2841
@@ -45,15 +58,17 @@ def test_check_ndk_version_greater_than_recommended(self, mock_read_ndk):
4558 self .assertEqual (
4659 cm .output ,
4760 [
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+ )
5065 ),
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+ )
5470 ),
55- "WARNING:p4a:[WARNING]:"
56- " Newer NDKs may not be fully supported by p4a." ,
71+ "WARNING:p4a:[WARNING]: {}" .format (NEW_NDK_MESSAGE ),
5772 ],
5873 )
5974
@@ -64,9 +79,8 @@ def test_check_ndk_version_lower_than_recommended(self, mock_read_ndk):
6479 check_ndk_version (self .ndk_dir )
6580 self .assertEqual (
6681 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
7084 ),
7185 )
7286 mock_read_ndk .assert_called_once_with (self .ndk_dir )
@@ -83,16 +97,17 @@ def test_check_ndk_version_error(self):
8397 self .assertEqual (
8498 cm .output ,
8599 [
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+ ),
96111 ],
97112 )
98113
@@ -119,10 +134,7 @@ def test_read_ndk_version_error(self, mock_open_src_prop):
119134 version = read_ndk_version (self .ndk_dir )
120135 self .assertEqual (
121136 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 )],
126138 )
127139 mock_open_src_prop .assert_called_once_with (
128140 join (self .ndk_dir , "source.properties" )
@@ -135,10 +147,9 @@ def test_check_target_api_error_arch_armeabi(self):
135147 check_target_api (RECOMMENDED_TARGET_API , "armeabi" )
136148 self .assertEqual (
137149 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 ,
142153 ),
143154 )
144155
@@ -151,10 +162,9 @@ def test_check_target_api_warning_target_api(self):
151162 cm .output ,
152163 [
153164 "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+ ),
158168 ],
159169 )
160170
@@ -169,8 +179,7 @@ def test_check_ndk_api_error_android_api(self):
169179 check_ndk_api (ndk_api , android_api )
170180 self .assertEqual (
171181 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 (
174183 ndk_api = ndk_api , android_api = android_api
175184 ),
176185 )
@@ -187,5 +196,9 @@ def test_check_ndk_api_warning_old_ndk(self):
187196 check_ndk_api (ndk_api , android_api )
188197 self .assertEqual (
189198 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+ ],
191204 )
0 commit comments