From dc34da123dd7ec1a076a4c5390e3aa9fe3b614a7 Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Mon, 17 Feb 2014 17:50:24 +0000 Subject: [PATCH 01/14] add assert methods for drawing and compiled paths --- enable/testing.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/enable/testing.py b/enable/testing.py index 54e937452..b787a8fe0 100644 --- a/enable/testing.py +++ b/enable/testing.py @@ -89,6 +89,13 @@ def create_mock_window(self): window.control.set_pointer = Mock() return window + def create_a_mock_gc(self, width, height): + gc = PlotGraphicsContext((width, height)) + gc.clear((0.0, 0.0, 0.0, 0.0)) + gc.stroke_path = Mock() + gc.draw_path = Mock() + return gc + def create_key_press(self, key, window=None, alt_down=False, control_down=False, shift_down=False): """ Creates a KeyEvent for the given Key. @@ -379,3 +386,63 @@ def _key_event_dispatch(self, interactor, event): interactor.dispatch(event, 'key_pressed') else: focus_owner.dispatch(event, 'key_pressed') + + def assertPathsAreProcessed(self, drawable, width=200, height=200): + """ Check that drawing does not leave paths unused in the GC cache. + + Parameters + ---------- + drawable : + A drawable object that has a draw method. + + width : int, optional + The width of the array buffer + + height : int, optional + The height of the array buffer + + """ + gc = PlotGraphicsContext((width, height)) + drawable.draw(gc) + compiled_path = gc._get_path() + self.assertEqual( + compiled_path.total_vertices(), 0, + msg='There are compiled paths that ' + 'have not been processed: {0}'.format(compiled_path)) + + def assertPathsAreCreated(self, drawable, width=200, height=200): + """ Check that drawing creates paths. + + Parameters + ---------- + drawable : + A drawable object that has a draw method. + + width : int, optional + The width of the array buffer + + height : int, optional + The height of the array buffer + + """ + gc = self.create_a_mock_gc(width, height) + drawable.draw(gc) + compiled_path = gc._get_path() + self.assertGreater( + compiled_path.total_vertices(), 0, + msg='There are no compiled paths ' + 'created: {0}'.format(compiled_path)) + + def _mouse_event_dispatch(self, interactor, event, suffix): + mouse_owner = event.window.mouse_owner + if mouse_owner is None: + interactor.dispatch(event, suffix) + else: + mouse_owner.dispatch(event, suffix) + + def _key_event_dispatch(self, interactor, event): + focus_owner = event.window.focus_owner + if focus_owner is None: + interactor.dispatch(event, 'key_pressed') + else: + focus_owner.dispatch(event, 'key_pressed') From d73de13c2f6eb378240882e9a55ddc50ab6f4370 Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 11:00:35 +0000 Subject: [PATCH 02/14] remove duplicate methods --- enable/testing.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/enable/testing.py b/enable/testing.py index b787a8fe0..482dbdd89 100644 --- a/enable/testing.py +++ b/enable/testing.py @@ -432,17 +432,3 @@ def assertPathsAreCreated(self, drawable, width=200, height=200): compiled_path.total_vertices(), 0, msg='There are no compiled paths ' 'created: {0}'.format(compiled_path)) - - def _mouse_event_dispatch(self, interactor, event, suffix): - mouse_owner = event.window.mouse_owner - if mouse_owner is None: - interactor.dispatch(event, suffix) - else: - mouse_owner.dispatch(event, suffix) - - def _key_event_dispatch(self, interactor, event): - focus_owner = event.window.focus_owner - if focus_owner is None: - interactor.dispatch(event, 'key_pressed') - else: - focus_owner.dispatch(event, 'key_pressed') From de70b7d22d489ee73eb843c4261b61e27de8d3dd Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 11:05:53 +0000 Subject: [PATCH 03/14] use the enable graphics context instead of a chaco one --- enable/testing.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/enable/testing.py b/enable/testing.py index 482dbdd89..3903ba1a6 100644 --- a/enable/testing.py +++ b/enable/testing.py @@ -4,6 +4,7 @@ from enable.abstract_window import AbstractWindow from enable.events import MouseEvent, KeyEvent +from enable.graphics_context import GraphicsContextImage class _MockWindow(AbstractWindow): @@ -89,8 +90,8 @@ def create_mock_window(self): window.control.set_pointer = Mock() return window - def create_a_mock_gc(self, width, height): - gc = PlotGraphicsContext((width, height)) + def create_mock_graphics_context(self, width, height): + gc = GraphicsContextImage((width, height)) gc.clear((0.0, 0.0, 0.0, 0.0)) gc.stroke_path = Mock() gc.draw_path = Mock() @@ -402,7 +403,7 @@ def assertPathsAreProcessed(self, drawable, width=200, height=200): The height of the array buffer """ - gc = PlotGraphicsContext((width, height)) + gc = GraphicsContextImage((width, height)) drawable.draw(gc) compiled_path = gc._get_path() self.assertEqual( From 35257877dea51ed483b3289bedffd0e313f33d67 Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 11:12:39 +0000 Subject: [PATCH 04/14] Add two options for custom draw_path and stroke_path methods --- enable/testing.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/enable/testing.py b/enable/testing.py index 3903ba1a6..552a7400a 100644 --- a/enable/testing.py +++ b/enable/testing.py @@ -90,11 +90,28 @@ def create_mock_window(self): window.control.set_pointer = Mock() return window - def create_mock_graphics_context(self, width, height): + def create_mock_graphics_context( + self, width, height, stroke_path=None, draw_path=None): + """ Create an image graphics context that will mock the stroke and + draw_path methods. + + Parameters + ---------- + width, height : + The size of the graphics context canvas. + + stroke_path : callable, optional + A callable to use as the stroke_path method (default is Mock()). + + draw_path : callable, optional + A callable to use as the draw_path method (default is Mock()). + + + """ gc = GraphicsContextImage((width, height)) gc.clear((0.0, 0.0, 0.0, 0.0)) - gc.stroke_path = Mock() - gc.draw_path = Mock() + gc.stroke_path = Mock() if stroke_path is None else stroke_path + gc.draw_path = Mock() if draw_path is None else draw_path return gc def create_key_press(self, key, window=None, alt_down=False, From c0b8e2e4cda3e9a3cef9f09a5cca07ffa7044e16 Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 11:15:50 +0000 Subject: [PATCH 05/14] minor cleanup --- enable/testing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/enable/testing.py b/enable/testing.py index 552a7400a..e192a74c0 100644 --- a/enable/testing.py +++ b/enable/testing.py @@ -437,13 +437,13 @@ def assertPathsAreCreated(self, drawable, width=200, height=200): A drawable object that has a draw method. width : int, optional - The width of the array buffer + The width of the array buffer (default is 200) height : int, optional - The height of the array buffer + The height of the array buffer (default is 200) """ - gc = self.create_a_mock_gc(width, height) + gc = self.create_mock_gc(width, height) drawable.draw(gc) compiled_path = gc._get_path() self.assertGreater( From 34b0e341423df8c258b64c700e96644aad6879db Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 12:02:03 +0000 Subject: [PATCH 06/14] move kive related assert methods to kiva from enable --- enable/testing.py | 71 --------------------------------------- kiva/testing.py | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 71 deletions(-) create mode 100644 kiva/testing.py diff --git a/enable/testing.py b/enable/testing.py index e192a74c0..54e937452 100644 --- a/enable/testing.py +++ b/enable/testing.py @@ -4,7 +4,6 @@ from enable.abstract_window import AbstractWindow from enable.events import MouseEvent, KeyEvent -from enable.graphics_context import GraphicsContextImage class _MockWindow(AbstractWindow): @@ -90,30 +89,6 @@ def create_mock_window(self): window.control.set_pointer = Mock() return window - def create_mock_graphics_context( - self, width, height, stroke_path=None, draw_path=None): - """ Create an image graphics context that will mock the stroke and - draw_path methods. - - Parameters - ---------- - width, height : - The size of the graphics context canvas. - - stroke_path : callable, optional - A callable to use as the stroke_path method (default is Mock()). - - draw_path : callable, optional - A callable to use as the draw_path method (default is Mock()). - - - """ - gc = GraphicsContextImage((width, height)) - gc.clear((0.0, 0.0, 0.0, 0.0)) - gc.stroke_path = Mock() if stroke_path is None else stroke_path - gc.draw_path = Mock() if draw_path is None else draw_path - return gc - def create_key_press(self, key, window=None, alt_down=False, control_down=False, shift_down=False): """ Creates a KeyEvent for the given Key. @@ -404,49 +379,3 @@ def _key_event_dispatch(self, interactor, event): interactor.dispatch(event, 'key_pressed') else: focus_owner.dispatch(event, 'key_pressed') - - def assertPathsAreProcessed(self, drawable, width=200, height=200): - """ Check that drawing does not leave paths unused in the GC cache. - - Parameters - ---------- - drawable : - A drawable object that has a draw method. - - width : int, optional - The width of the array buffer - - height : int, optional - The height of the array buffer - - """ - gc = GraphicsContextImage((width, height)) - drawable.draw(gc) - compiled_path = gc._get_path() - self.assertEqual( - compiled_path.total_vertices(), 0, - msg='There are compiled paths that ' - 'have not been processed: {0}'.format(compiled_path)) - - def assertPathsAreCreated(self, drawable, width=200, height=200): - """ Check that drawing creates paths. - - Parameters - ---------- - drawable : - A drawable object that has a draw method. - - width : int, optional - The width of the array buffer (default is 200) - - height : int, optional - The height of the array buffer (default is 200) - - """ - gc = self.create_mock_gc(width, height) - drawable.draw(gc) - compiled_path = gc._get_path() - self.assertGreater( - compiled_path.total_vertices(), 0, - msg='There are no compiled paths ' - 'created: {0}'.format(compiled_path)) diff --git a/kiva/testing.py b/kiva/testing.py new file mode 100644 index 000000000..48170b5ab --- /dev/null +++ b/kiva/testing.py @@ -0,0 +1,85 @@ +# Copyright (c) 2008-2013 by Enthought, Inc. +# All rights reserved. +from mock import Mock + +from kiva.image import GraphicsContext + + +class KivaTestAssistant(object): + """ Mixin test helper for kiva drawing tests. + + """ + + def create_mock_gc( + self, width, height, stroke_path=None, draw_path=None): + """ Create an image graphics context that will mock the stroke_path + and draw_path methods. + + Parameters + ---------- + width, height : + The size of the graphics context canvas. + + stroke_path : callable, optional + A callable to use as the stroke_path method (default is Mock()). + + draw_path : callable, optional + A callable to use as the draw_path method (default is Mock()). + + + """ + gc = GraphicsContext((width, height)) + gc.clear((0.0, 0.0, 0.0, 0.0)) + gc.stroke_path = Mock() if stroke_path is None else stroke_path + gc.draw_path = Mock() if draw_path is None else draw_path + return gc + + def assertPathsAreProcessed(self, drawable, width=200, height=200): + """ Check that drawing does not leave paths unused in the GC cache. + + When drawing paths are created + + Parameters + ---------- + drawable : + A drawable object that has a draw method. + + width : int, optional + The width of the array buffer + + height : int, optional + The height of the array buffer + + """ + gc = GraphicsContext((width, height)) + drawable.draw(gc) + compiled_path = gc._get_path() + self.assertEqual( + compiled_path.total_vertices(), 0, + msg='There are compiled paths that ' + 'have not been processed: {0}'.format(compiled_path)) + + def assertPathsAreCreated(self, drawable, width=200, height=200): + """ Check that drawing creates paths. + + + + Parameters + ---------- + drawable : + A drawable object that has a draw method. + + width : int, optional + The width of the array buffer (default is 200) + + height : int, optional + The height of the array buffer (default is 200) + + """ + gc = self.create_mock_gc(width, height) + drawable.draw(gc) + compiled_path = gc._get_path() + self.assertGreater( + compiled_path.total_vertices(), 0, + msg='There are no compiled paths ' + 'created: {0}'.format(compiled_path)) From 77ffa14b4723002c839fc9253ae7c0c1cb539744 Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 13:13:25 +0000 Subject: [PATCH 07/14] add tests for the KivaTestAssistant --- kiva/testing.py | 25 ++++++++----- kiva/tests/test_kiva_test_assistant.py | 52 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 kiva/tests/test_kiva_test_assistant.py diff --git a/kiva/testing.py b/kiva/testing.py index 48170b5ab..7f4921875 100644 --- a/kiva/testing.py +++ b/kiva/testing.py @@ -28,7 +28,7 @@ def create_mock_gc( """ - gc = GraphicsContext((width, height)) + gc = GraphicsContext((int(width), int(height))) gc.clear((0.0, 0.0, 0.0, 0.0)) gc.stroke_path = Mock() if stroke_path is None else stroke_path gc.draw_path = Mock() if draw_path is None else draw_path @@ -37,7 +37,9 @@ def create_mock_gc( def assertPathsAreProcessed(self, drawable, width=200, height=200): """ Check that drawing does not leave paths unused in the GC cache. - When drawing paths are created + The method checks that there is something drawn into the + graphics context and then that all the paths have been compiled + and processed successfully. Parameters ---------- @@ -45,24 +47,27 @@ def assertPathsAreProcessed(self, drawable, width=200, height=200): A drawable object that has a draw method. width : int, optional - The width of the array buffer + The width of the array buffer (default is 200). height : int, optional - The height of the array buffer + The height of the array buffer (default is 200). """ + # check first that something is drawn to the graphics context. gc = GraphicsContext((width, height)) drawable.draw(gc) compiled_path = gc._get_path() + total_vertices = compiled_path.total_vertices() self.assertEqual( - compiled_path.total_vertices(), 0, - msg='There are compiled paths that ' - 'have not been processed: {0}'.format(compiled_path)) + total_vertices, 0, + msg='There are {0} vertices in compiled paths {1} that ' + 'have not been processed'.format(total_vertices, compiled_path)) def assertPathsAreCreated(self, drawable, width=200, height=200): """ Check that drawing creates paths. - + When paths and lines creation methods are used from a graphics + context the drawing paths are compiled and processed. Parameters ---------- @@ -70,10 +75,10 @@ def assertPathsAreCreated(self, drawable, width=200, height=200): A drawable object that has a draw method. width : int, optional - The width of the array buffer (default is 200) + The width of the array buffer (default is 200). height : int, optional - The height of the array buffer (default is 200) + The height of the array buffer (default is 200). """ gc = self.create_mock_gc(width, height) diff --git a/kiva/tests/test_kiva_test_assistant.py b/kiva/tests/test_kiva_test_assistant.py new file mode 100644 index 000000000..bc1d598b8 --- /dev/null +++ b/kiva/tests/test_kiva_test_assistant.py @@ -0,0 +1,52 @@ +import unittest + +from kiva.testing import KivaTestAssistant + + +class Drawable(object): + + def __init__(self, should_draw=True, should_process=True): + self.should_draw = should_draw + self.should_process = should_process + + def draw(self, gc): + with gc: + if self.should_draw: + gc.move_to(-5,0) + gc.line_to(5,0) + gc.move_to(0,5) + gc.line_to(0,-5) + gc.move_to(0,0) + # The path will not be processed and remain in the gc cache + # if we do not execute the stroke_path command. + if self.should_process: + gc.stroke_path() + + +class TestKivaTestAssistant(KivaTestAssistant, unittest.TestCase): + + def test_path_created_assertions(self): + drawable = Drawable(should_draw=False) + + # drawing nothing + with self.assertRaises(AssertionError): + self.assertPathsAreCreated(drawable) + + #drawing something + drawable.should_draw = True + self.assertPathsAreCreated(drawable) + + def test_paths_processed_assertions(self): + drawable = Drawable(should_draw=True, should_process=False) + + # drawing nothing + with self.assertRaises(AssertionError): + self.assertPathsAreProcessed(drawable) + + #drawing something + drawable.should_process = True + self.assertPathsAreProcessed(drawable) + + +if __name__ == '__main__': + unittest.main() From f3c6af10884441b99991c3d82a90b77aff8cc927 Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 13:15:47 +0000 Subject: [PATCH 08/14] subclass EableTestAssistant from KivaTestAssistant --- enable/testing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/enable/testing.py b/enable/testing.py index 54e937452..9fffed7b5 100644 --- a/enable/testing.py +++ b/enable/testing.py @@ -4,6 +4,7 @@ from enable.abstract_window import AbstractWindow from enable.events import MouseEvent, KeyEvent +from kiva.testing import KivaTestAssistant class _MockWindow(AbstractWindow): @@ -15,7 +16,7 @@ def _redraw(self, coordinates=None): pass -class EnableTestAssistant(object): +class EnableTestAssistant(KivaTestAssistant): """ Mixin helper for enable/chaco components. """ From 272c4b93a32f4b82e2c27890ae27367d1a5cce47 Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 13:18:34 +0000 Subject: [PATCH 09/14] pep8 and pyflakes --- enable/testing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/enable/testing.py b/enable/testing.py index 9fffed7b5..b2698aaf8 100644 --- a/enable/testing.py +++ b/enable/testing.py @@ -6,6 +6,7 @@ from enable.events import MouseEvent, KeyEvent from kiva.testing import KivaTestAssistant + class _MockWindow(AbstractWindow): # FIXME: for some reason I cannot replace these functions with a Mock From acc2c3fcc90c5a8c7b685c0b38c9bcb0bea71a05 Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 13:24:24 +0000 Subject: [PATCH 10/14] clean up comments --- kiva/testing.py | 14 +++++++------- kiva/tests/test_kiva_test_assistant.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kiva/testing.py b/kiva/testing.py index 7f4921875..5b2c77aca 100644 --- a/kiva/testing.py +++ b/kiva/testing.py @@ -35,11 +35,7 @@ def create_mock_gc( return gc def assertPathsAreProcessed(self, drawable, width=200, height=200): - """ Check that drawing does not leave paths unused in the GC cache. - - The method checks that there is something drawn into the - graphics context and then that all the paths have been compiled - and processed successfully. + """ Check that all the paths have been compiled and processed. Parameters ---------- @@ -52,8 +48,11 @@ def assertPathsAreProcessed(self, drawable, width=200, height=200): height : int, optional The height of the array buffer (default is 200). + note :: + + A drawable that draws nothing will pass this check. + """ - # check first that something is drawn to the graphics context. gc = GraphicsContext((width, height)) drawable.draw(gc) compiled_path = gc._get_path() @@ -67,7 +66,8 @@ def assertPathsAreCreated(self, drawable, width=200, height=200): """ Check that drawing creates paths. When paths and lines creation methods are used from a graphics - context the drawing paths are compiled and processed. + context the drawing paths are compiled and processed. By using + a mock graphics context we can check if something has been drawn. Parameters ---------- diff --git a/kiva/tests/test_kiva_test_assistant.py b/kiva/tests/test_kiva_test_assistant.py index bc1d598b8..08528a9bb 100644 --- a/kiva/tests/test_kiva_test_assistant.py +++ b/kiva/tests/test_kiva_test_assistant.py @@ -39,7 +39,7 @@ def test_path_created_assertions(self): def test_paths_processed_assertions(self): drawable = Drawable(should_draw=True, should_process=False) - # drawing nothing + # not finishing the path with self.assertRaises(AssertionError): self.assertPathsAreProcessed(drawable) From 7b12d9a1e0ee532623a34ad1005ffb06e453cece Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 13:29:10 +0000 Subject: [PATCH 11/14] support python 2.6.x --- kiva/tests/test_kiva_test_assistant.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kiva/tests/test_kiva_test_assistant.py b/kiva/tests/test_kiva_test_assistant.py index 08528a9bb..c7b7065b2 100644 --- a/kiva/tests/test_kiva_test_assistant.py +++ b/kiva/tests/test_kiva_test_assistant.py @@ -29,8 +29,9 @@ def test_path_created_assertions(self): drawable = Drawable(should_draw=False) # drawing nothing - with self.assertRaises(AssertionError): - self.assertPathsAreCreated(drawable) + self.assertRaises(AssertionError, + self.assertPathsAreCreated, + drawable) #drawing something drawable.should_draw = True @@ -40,8 +41,10 @@ def test_paths_processed_assertions(self): drawable = Drawable(should_draw=True, should_process=False) # not finishing the path - with self.assertRaises(AssertionError): - self.assertPathsAreProcessed(drawable) + self.assertRaises( + AssertionError, + self.assertPathsAreProcessed, + drawable) #drawing something drawable.should_process = True From 4761ec7322aa77b4527b1cd8d6f35a7db66cc041 Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 13:44:20 +0000 Subject: [PATCH 12/14] more python 2.6.x support --- kiva/testing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kiva/testing.py b/kiva/testing.py index 5b2c77aca..59fb757ec 100644 --- a/kiva/testing.py +++ b/kiva/testing.py @@ -84,7 +84,7 @@ def assertPathsAreCreated(self, drawable, width=200, height=200): gc = self.create_mock_gc(width, height) drawable.draw(gc) compiled_path = gc._get_path() - self.assertGreater( - compiled_path.total_vertices(), 0, + self.assertTrue( + compiled_path.total_vertices() > 0, msg='There are no compiled paths ' 'created: {0}'.format(compiled_path)) From ced7aee3b52832bb2acd07601cfac0d7a23ed9bd Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 16:44:55 +0000 Subject: [PATCH 13/14] rework the create_mock_gc to accept the method names for which a Mock() will be used --- kiva/testing.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/kiva/testing.py b/kiva/testing.py index 59fb757ec..502c144c0 100644 --- a/kiva/testing.py +++ b/kiva/testing.py @@ -11,7 +11,7 @@ class KivaTestAssistant(object): """ def create_mock_gc( - self, width, height, stroke_path=None, draw_path=None): + self, width, height, methods=()): """ Create an image graphics context that will mock the stroke_path and draw_path methods. @@ -20,18 +20,14 @@ def create_mock_gc( width, height : The size of the graphics context canvas. - stroke_path : callable, optional - A callable to use as the stroke_path method (default is Mock()). - - draw_path : callable, optional - A callable to use as the draw_path method (default is Mock()). - + methods : iterable + the methods which are going to be mocked with a Mock object. """ gc = GraphicsContext((int(width), int(height))) gc.clear((0.0, 0.0, 0.0, 0.0)) - gc.stroke_path = Mock() if stroke_path is None else stroke_path - gc.draw_path = Mock() if draw_path is None else draw_path + for method in methods: + setattr(gc, method, Mock()) return gc def assertPathsAreProcessed(self, drawable, width=200, height=200): @@ -81,7 +77,7 @@ def assertPathsAreCreated(self, drawable, width=200, height=200): The height of the array buffer (default is 200). """ - gc = self.create_mock_gc(width, height) + gc = self.create_mock_gc(width, height, ('draw_path', 'stroke_path')) drawable.draw(gc) compiled_path = gc._get_path() self.assertTrue( From 6252681a4ecd1b07399ab02baeec80196d7b338f Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Wed, 19 Feb 2014 16:46:09 +0000 Subject: [PATCH 14/14] update docstring --- kiva/testing.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kiva/testing.py b/kiva/testing.py index 502c144c0..0b4af3116 100644 --- a/kiva/testing.py +++ b/kiva/testing.py @@ -12,8 +12,7 @@ class KivaTestAssistant(object): def create_mock_gc( self, width, height, methods=()): - """ Create an image graphics context that will mock the stroke_path - and draw_path methods. + """ Create an image graphics context that with mocked methods. Parameters ----------