on xenial help sign in
Separation of concerns, leave environment setup to those that own the environment. (req. that unity8 is stopped before running tests.)
8adfc69Christopher Lee
tests/autopilot/unity8/shell/tests/__init__.py+8−16
@@ -33,6 +33,7 @@ from autopilot.display import Display
33import logging
33import logging
34import os.path
34import os.path
35import subprocess
35import subprocess
36+import sys
36from testtools.matchers import Equals, NotEquals
37from testtools.matchers import Equals, NotEquals
37
38
38from unity8 import (
39from unity8 import (
@@ -81,8 +82,6 @@ class UnityTestCase(AutopilotTestCase):
81
82
82 """A test case base class for the Unity shell tests."""
83 """A test case base class for the Unity shell tests."""
83
84
84− __unity_was_running_before_tests = False
85−
86 @classmethod
85 @classmethod
87 def setUpClass(cls):
86 def setUpClass(cls):
88 output = subprocess.check_output([
87 output = subprocess.check_output([
@@ -92,20 +91,13 @@ class UnityTestCase(AutopilotTestCase):
92 ])
91 ])
93
92
94 if "start/" in output:
93 if "start/" in output:
95− UnityTestCase.__unity_was_running_before_tests = True
94+ sys.stderr.write(
96− logger.info("Stopping existing Unity")
95+ "Error: Unity is currently running, these tests require it to "
97− try:
96+ "be 'stopped'.\n"
98− subprocess.check_call(["/sbin/initctl", "stop", "unity8"])
97+ "Please run this command before running these tests: \n"
99− except subprocess.CalledProcessError as e:
98+ "initctl stop unity\n"
100− logger.warning("Unable to stop unity8")
99+ )
101− e.args += ("Failed to stop existing unity8 process", )
100+ sys.exit(1)
102− raise
103−
104− @classmethod
105− def tearDownClass(cls):
106− if UnityTestCase.__unity_was_running_before_tests:
107− logger.info("Starting unity again with original env")
108− subprocess.check_call(["/sbin/initctl", "start", "unity8"])
109
101
110 def setUp(self):
102 def setUp(self):
111 super(UnityTestCase, self).setUp()
103 super(UnityTestCase, self).setUp()