on xenial help sign in
Use readable options and _patch_environment for QT_LOAD_TESTABILITY, too.
d86f637Michał Sawicz
tests/autopilot/unity8/shell/tests/__init__.py+5−12
@@ -190,14 +190,12 @@ class UnityTestCase(AutopilotTestCase):
190 return divisor
190 return divisor
191
191
192 def _patch_environment(self, key, value):
192 def _patch_environment(self, key, value):
193− """Wrapper for patching env for either upstart or non-upstart
193+ """Wrapper for patching env for upstart environment."""
194− environments.
195−
196− """
197 try:
194 try:
198 current_value = subprocess.check_output([
195 current_value = subprocess.check_output([
199 "/sbin/initctl",
196 "/sbin/initctl",
200 "get-env",
197 "get-env",
198+ "--global",
201 key
199 key
202 ]).rstrip()
200 ]).rstrip()
203 except subprocess.CalledProcessError:
201 except subprocess.CalledProcessError:
@@ -206,7 +204,7 @@ class UnityTestCase(AutopilotTestCase):
206 subprocess.call([
204 subprocess.call([
207 "/sbin/initctl",
205 "/sbin/initctl",
208 "set-env",
206 "set-env",
209− "-g",
207+ "--global",
210 "%s=%s" % (key, value)
208 "%s=%s" % (key, value)
211 ])
209 ])
212 self.addCleanup(self._upstart_reset_env, key, current_value)
210 self.addCleanup(self._upstart_reset_env, key, current_value)
@@ -219,6 +217,7 @@ class UnityTestCase(AutopilotTestCase):
219 subprocess.call([
217 subprocess.call([
220 "/sbin/initctl",
218 "/sbin/initctl",
221 "set-env",
219 "set-env",
220+ "--global",
222 "%s=%s" % (key, value)
221 "%s=%s" % (key, value)
223 ])
222 ])
224
223
@@ -265,12 +264,7 @@ class UnityTestCase(AutopilotTestCase):
265 return app_proxy
264 return app_proxy
266
265
267 def _launch_unity_with_upstart(self, binary_path, args):
266 def _launch_unity_with_upstart(self, binary_path, args):
268− subprocess.call([
269− "/sbin/initctl",
270− "set-env",
271− "-g",
272− "QT_LOAD_TESTABILITY=1"
267+ self._patch_environment("QT_LOAD_TESTABILITY", 1)
273− ])
274
268
275 binary_arg = "BINARY=%s" % binary_path
269 binary_arg = "BINARY=%s" % binary_path
276 extra_args = "ARGS=%s" % " ".join(args)
270 extra_args = "ARGS=%s" % " ".join(args)
@@ -294,7 +288,6 @@ class UnityTestCase(AutopilotTestCase):
294
288
295 def _cleanup_launching_upstart_unity(self):
289 def _cleanup_launching_upstart_unity(self):
296 logger.info("Cleaning up launching unity")
290 logger.info("Cleaning up launching unity")
297− subprocess.call(["/sbin/initctl", "unset-env", "QT_LOAD_TESTABILITY"])
298
291
299 # Workaround for issue: lp:1239491
292 # Workaround for issue: lp:1239491
300 if model() != "Desktop":
293 if model() != "Desktop":