@@ -28,12 +28,14 @@ don't break them for those external projects.
2828"""
2929
3030import os
31+import sysconfig
3132
3233import mock
3334
3435import fixtures
3536from testtools.matchers import Contains, HasLength
3637
38+import unity8
3739from unity8 import process_helpers
3840from unity8.shell import emulators, tests
3941from unity8.shell.emulators import dash as dash_emulators
@@ -51,14 +53,26 @@ class DashBaseTestCase(tests.UnityTestCase):
5153 self.dash = self.main_window.get_dash()
5254
5355 def _use_scope_fakes(self):
54− qml2_import_path = os.environ.get('QML2_IMPORT_PATH')
55− mocks_path = os.path.join(
56− os.getcwd(), '../..', 'builddir/tests/mocks')
57− qml_import_path_with_scope_fakes = '{0}:{1}'.format(
58− qml2_import_path, mocks_path)
59− self.useFixture(fixtures.EnvironmentVariable(
60− 'QML2_IMPORT_PATH',
61− newvalue=qml_import_path_with_scope_fakes))
56+ self.useFixture(
57+ fixtures.EnvironmentVariable(
58+ 'QML2_IMPORT_PATH',
59+ newvalue=self._get_fake_scopes_library_path()))
60+
61+ def _get_fake_scopes_library_path(self):
62+ if unity8.running_installed_tests():
63+ mock_path = 'qml/scopefakes/'
64+ else:
65+ mock_path = os.path.join(
66+ '../lib/', sysconfig.get_config_var('MULTIARCH'),
67+ 'unity8/qml/scopefakes/')
68+ lib_path = unity8.get_lib_path()
69+ ld_library_path = os.path.abspath(os.path.join(lib_path, mock_path))
70+
71+ if not os.path.exists(ld_library_path):
72+ raise RuntimeError(
73+ 'Expected library path does not exists: %s.' % (
74+ ld_library_path))
75+ return ld_library_path
6276
6377
6478class DashEmulatorTestCase(DashBaseTestCase):