1
by Varun Hiremath
Import upstream version 3.0.2 |
1 |
import os |
2 |
import unittest |
|
3 |
||
4 |
from numpy import allclose, ravel |
|
5 |
||
6 |
import nose |
|
7 |
||
8 |
from enthought.kiva import agg |
|
9 |
||
10 |
||
11 |
# FIXME:
|
|
12 |
# These tests are broken, and Peter promised to fix it at some point.
|
|
13 |
||
14 |
class Test_Save(unittest.TestCase): |
|
15 |
format_output_map = { |
|
16 |
"rgb24": [255,255,255,255,255,255,255,0,0,255,0,0], |
|
17 |
"bgr24": [255,255,255,255,255,255,0,0,255,0,0,255], |
|
18 |
"rgba32": [255,255,255,255,255,255,255,255,255,0,0,255,255,0,0,255], |
|
19 |
"bgra32": [255,255,255,255,255,255,255,255,0,0,255,255,0,0,255,255] |
|
20 |
}
|
|
1.2.1
by Varun Hiremath
Import upstream version 3.4.1 |
21 |
|
1
by Varun Hiremath
Import upstream version 3.0.2 |
22 |
def test_rgb24_format(self): |
23 |
self.do_check_format('rgb24') |
|
1.2.1
by Varun Hiremath
Import upstream version 3.4.1 |
24 |
|
1
by Varun Hiremath
Import upstream version 3.0.2 |
25 |
def test_bgr24_format(self): |
26 |
self.do_check_format('bgr24') |
|
1.2.1
by Varun Hiremath
Import upstream version 3.4.1 |
27 |
|
1
by Varun Hiremath
Import upstream version 3.0.2 |
28 |
def test_rgba32_format(self): |
29 |
self.do_check_format('rgba32') |
|
1.2.1
by Varun Hiremath
Import upstream version 3.4.1 |
30 |
|
1
by Varun Hiremath
Import upstream version 3.0.2 |
31 |
def test_bgra32_format(self): |
32 |
self.do_check_format('bgra32') |
|
1.2.1
by Varun Hiremath
Import upstream version 3.4.1 |
33 |
|
1
by Varun Hiremath
Import upstream version 3.0.2 |
34 |
def do_check_format(self,fmt): |
35 |
# FIXME:
|
|
36 |
raise nose.SkipTest |
|
37 |
||
38 |
gc = agg.GraphicsContextArray((2,2), fmt) |
|
39 |
gc.set_stroke_color((1.0,0.0,0.0)) |
|
40 |
gc.move_to(0.0, 0.5) |
|
41 |
gc.line_to(2.0, 0.5) |
|
42 |
gc.stroke_path() |
|
43 |
gc.save(fmt + ".png") |
|
44 |
img = agg.Image(fmt + ".png") |
|
45 |
os.unlink(fmt + ".png") |
|
46 |
self.assertEqual(list(ravel(img.bmp_array)), |
|
47 |
self.format_output_map[fmt]) |
|
48 |
||
49 |
if __name__ == "__main__": |
|
50 |
unittest.main() |