[mousetrap/gnome3-wip: 149/240] Fix tests.
- From: Heidi Ellis <heidiellis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetrap/gnome3-wip: 149/240] Fix tests.
- Date: Mon, 8 Sep 2014 15:25:05 +0000 (UTC)
commit 92f93ebaf5c36056587489aa7b845170fb021099
Author: Stoney Jackson <dr stoney gmail com>
Date: Tue Jun 24 10:12:39 2014 -0400
Fix tests.
src/mousetrap/main.py | 15 +++++++++++----
src/mousetrap/tests/test_mouse_pointer.py | 5 +++--
src/mousetrap/tests/test_vision.py | 11 +++--------
3 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/src/mousetrap/main.py b/src/mousetrap/main.py
index 950b5b1..73f9a75 100644
--- a/src/mousetrap/main.py
+++ b/src/mousetrap/main.py
@@ -40,10 +40,17 @@ class App(object):
self.plugins.append(self._load_plugin(class_))
def _load_plugin(self, class_):
- LOGGER.debug('loading %s', class_)
- class_path = class_.split('.')
- module = __import__('.'.join(class_path[:-1]), {}, {}, class_path[-1])
- return getattr(module, class_path[-1])(self.config)
+ try:
+ LOGGER.debug('loading %s', class_)
+ class_path = class_.split('.')
+ module = __import__('.'.join(class_path[:-1]), {}, {}, class_path[-1])
+ return getattr(module, class_path[-1])(self.config)
+ except ImportError as error:
+ LOGGER.error(
+ '''Could not import plugin `%s`. Check the config file and
+ PYTHONPATH to ensure that Python can find the plugin.'''
+ )
+ raise
def _register_plugins_with_loop(self):
for plugin in self.plugins:
diff --git a/src/mousetrap/tests/test_mouse_pointer.py b/src/mousetrap/tests/test_mouse_pointer.py
index 20287f0..00b143c 100644
--- a/src/mousetrap/tests/test_mouse_pointer.py
+++ b/src/mousetrap/tests/test_mouse_pointer.py
@@ -1,11 +1,12 @@
import unittest
-from mousetrap.gui import ScreenPointer
+from mousetrap.gui import Pointer
+from mousetrap.main import Config
class test_pointer(unittest.TestCase):
def setUp(self):
- self.pointer = ScreenPointer()
+ self.pointer = Pointer(Config())
def test_get_position(self):
pointer_x, pointer_y = self.pointer.get_position()
diff --git a/src/mousetrap/tests/test_vision.py b/src/mousetrap/tests/test_vision.py
index f01528a..876693b 100644
--- a/src/mousetrap/tests/test_vision.py
+++ b/src/mousetrap/tests/test_vision.py
@@ -1,17 +1,12 @@
import unittest
-import mousetrap.vision as vision
+from mousetrap.vision import Camera
+from mousetrap.main import Config
-# OpenCV will automatically search for a working camera device if we use the
-# index -1.
-DEVICE_INDEX = -1
-IMAGE_MAX_WIDTH = 400
-IMAGE_MAX_HEIGHT = 300
class test_camera(unittest.TestCase):
def setUp(self):
- self.camera = vision.Camera(DEVICE_INDEX,
- IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT)
+ self.camera = Camera(Config())
def test_get_image_imageReturned(self):
image = self.camera.read_image()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]