File: kiva_graphics_context_test_case.py

package info (click to toggle)
python-enable 4.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 7,280 kB
  • ctags: 13,899
  • sloc: cpp: 48,447; python: 28,502; ansic: 9,004; makefile: 315; sh: 44
file content (24 lines) | stat: -rw-r--r-- 765 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

import numpy as np
import unittest

from enable.kiva_graphics_context import GraphicsContext


class TestGCErrors(unittest.TestCase):
    """Test some cases where a ValueError should be raised."""

    def test_bad_image_size(self):
        arr = np.array([[1, 2], [3, 4]], dtype=np.uint8)
        gc = GraphicsContext((50, 50))
        # The draw_image methods expects its first argument
        # to be a 3D whose last dimension has lenght 3 or 4.
        # Passing in arr should raise a value error.
        self.assertRaises(ValueError, gc.draw_image, arr)

        # Pass in a 3D array, but with an invalid size in the last dimension.
        self.assertRaises(ValueError, gc.draw_image, arr.reshape(2, 2, 1))


if __name__ == "__main__":
    unittest.main()