@@ -33,6 +33,7 @@ from autopilot.display import Display
3333import logging
3434import os.path
3535import subprocess
36+import sys
3637from testtools.matchers import Equals, NotEquals
3738
3839from unity8 import (
@@ -81,8 +82,6 @@ class UnityTestCase(AutopilotTestCase):
8182
8283 """A test case base class for the Unity shell tests."""
8384
84− __unity_was_running_before_tests = False
85−
8685 @classmethod
8786 def setUpClass(cls):
8887 output = subprocess.check_output([
@@ -92,20 +91,13 @@ class UnityTestCase(AutopilotTestCase):
9291 ])
9392
9493 if "start/" in output:
95− UnityTestCase.__unity_was_running_before_tests = True
96− logger.info("Stopping existing Unity")
97− try:
98− subprocess.check_call(["/sbin/initctl", "stop", "unity8"])
99− except subprocess.CalledProcessError as e:
100− logger.warning("Unable to stop unity8")
101− e.args += ("Failed to stop existing unity8 process", )
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"])
94+ sys.stderr.write(
95+ "Error: Unity is currently running, these tests require it to "
96+ "be 'stopped'.\n"
97+ "Please run this command before running these tests: \n"
98+ "initctl stop unity\n"
99+ )
100+ sys.exit(1)
109101
110102 def setUp(self):
111103 super(UnityTestCase, self).setUp()