on xenial help sign in
Removed helpers.py
commite226799543cd66cd670944b8ec2ac2b8a933ec38 authorChristopher Lee <chris.lee@canonical.com> dateWed 17 Jul 2013, 11:32 (13 years ago) parent084ae64
4 files changed+35−43
tests/autopilot/unity8/__init__.py+1 tests/autopilot/unity8/shell/__init__.py+33 tests/autopilot/unity8/shell/tests/helpers.py−42 tests/autopilot/unity8/shell/tests/test_lock_screen.py+1−1
tests/autopilot/unity8/__init__.py+1
@@ -39,3 +39,4 @@ def get_unity8_binary_path():
3939 except subprocess.CalledProcessError as e:
4040 raise RuntimeError("Unable to locate unity8 binary: %r" % e)
4141 return binary_path
42+
tests/autopilot/unity8/shell/__init__.py+33
@@ -6,3 +6,36 @@
66# by the Free Software Foundation.
77
88"""unity8 shell autopilot tests and emulators - sub level package."""
9+
10+from functools import wraps
11+import os.path
12+
13+from unity8 import get_lib_path
14+
15+import logging
16+
17+logger = logging.getLogger(__name__)
18+
19+
20+def with_lightdm_mock(mock_type):
21+ """A simple decorator that sets up the LightDM mock for a single test."""
22+ def with_lightdm_mock_internal(fn):
23+ @wraps(fn)
24+ def wrapper(*args, **kwargs):
25+ logger.info("Setting up LightDM mock type '%s'", mock_type)
26+ lib_path = get_lib_path()
27+ new_ld_library_path = os.path.join(
28+ lib_path,
29+ "qml/mocks/LightDM/",
30+ mock_type
31+ )
32+ if not os.path.exists(new_ld_library_path):
33+ raise RuntimeError(
34+ "LightDM mock '%s' does not exist." % mock_type
35+ )
36+
37+ logger.info("New library path: %s", new_ld_library_path)
38+ args[0].patch_environment('LD_LIBRARY_PATH', new_ld_library_path)
39+ return fn(*args, **kwargs)
40+ return wrapper
41+ return with_lightdm_mock_internal
tests/autopilot/unity8/shell/tests/helpers.pydeleted−42
@@ -1,42 +0,0 @@
1−# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−# Copyright 2013 Canonical
3−#
4−# This program is free software: you can redistribute it and/or modify it
5−# under the terms of the GNU General Public License version 3, as published
6−# by the Free Software Foundation.
7−
8−from autopilot.matchers import Eventually
9−from testtools.matchers import Equals, NotEquals
10−from functools import wraps
11−import os.path
12−
13−from unity8 import get_lib_path
14−
15−
16−import logging
17−
18−logger = logging.getLogger(__name__)
19−
20−
21−def with_lightdm_mock(mock_type):
22− """A simple decorator that sets up the LightDM mock for a single test."""
23− def with_lightdm_mock_internal(fn):
24− @wraps(fn)
25− def wrapper(*args, **kwargs):
26− logger.info("Setting up LightDM mock type '%s'", mock_type)
27− lib_path = get_lib_path()
28− new_ld_library_path = os.path.join(
29− lib_path,
30− "qml/mocks/LightDM/",
31− mock_type
32− )
33− if not os.path.exists(new_ld_library_path):
34− raise RuntimeError(
35− "LightDM mock '%s' does not exist." % mock_type
36− )
37−
38− logger.info("New library path: %s", new_ld_library_path)
39− args[0].patch_environment('LD_LIBRARY_PATH', new_ld_library_path)
40− return fn(*args, **kwargs)
41− return wrapper
42− return with_lightdm_mock_internal
tests/autopilot/unity8/shell/tests/test_lock_screen.py+1−1
@@ -8,8 +8,8 @@
88
99from __future__ import absolute_import
1010
11+from unity8.shell import with_lightdm_mock
1112from unity8.shell.tests import Unity8TestCase, _get_device_emulation_scenarios
12−from unity8.shell.tests.helpers import with_lightdm_mock
1313
1414from autopilot.matchers import Eventually
1515from autopilot.platform import model