/usr/lib/python2.7/dist-packages/kiva/testing.py is in python-enable 4.5.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 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, methods=()):
        """ Create an image graphics context that with mocked methods.
        Parameters
        ----------
        width, height :
            The size of the graphics context canvas.
        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))
        for method in methods:
            setattr(gc, method, Mock())
        return gc
    def assertPathsAreProcessed(self, drawable, width=200, height=200):
        """ Check that all the paths have been compiled and processed.
        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).
        note ::
           A drawable that draws nothing will pass this check.
        """
        gc = GraphicsContext((width, height))
        drawable.draw(gc)
        compiled_path = gc._get_path()
        total_vertices = compiled_path.total_vertices()
        self.assertEqual(
            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. By using
        a mock graphics context we can check if something has been drawn.
        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, ('draw_path', 'stroke_path'))
        drawable.draw(gc)
        compiled_path = gc._get_path()
        self.assertTrue(
            compiled_path.total_vertices() > 0,
            msg='There are no compiled paths '
            'created: {0}'.format(compiled_path))
 |