adjust to new error/warning messages
[PyX.git] / test / unit / test_deco.py
blob416c9c9173dadaaff70f03620a1e0ca758ea67af
1 import sys
2 if sys.path[0] != "../..":
3 sys.path.insert(0, "../..")
5 import unittest
7 from pyx import *
8 from pyx.deco import *
10 class DecoTestCase(unittest.TestCase):
12 def testExcluderange(self):
13 d = decoratedpath(path.line(0, 0, 1, 0))
14 d.ensurenormpath()
15 d.excluderange(0.1, 0.2)
16 d.excluderange(0.5, 0.6)
17 d.excluderange(0.3, 0.4)
18 self.assertEqual(len(d.nostrokeranges), 3)
19 self.assertAlmostEqual(d.nostrokeranges[0][0], 0.1)
20 self.assertAlmostEqual(d.nostrokeranges[0][1], 0.2)
21 self.assertAlmostEqual(d.nostrokeranges[1][0], 0.3)
22 self.assertAlmostEqual(d.nostrokeranges[1][1], 0.4)
23 self.assertAlmostEqual(d.nostrokeranges[2][0], 0.5)
24 self.assertAlmostEqual(d.nostrokeranges[2][1], 0.6)
26 d.excluderange(0.52, 0.58)
27 self.assertEqual(len(d.nostrokeranges), 3)
28 self.assertAlmostEqual(d.nostrokeranges[0][0], 0.1)
29 self.assertAlmostEqual(d.nostrokeranges[0][1], 0.2)
30 self.assertAlmostEqual(d.nostrokeranges[1][0], 0.3)
31 self.assertAlmostEqual(d.nostrokeranges[1][1], 0.4)
32 self.assertAlmostEqual(d.nostrokeranges[2][0], 0.5)
33 self.assertAlmostEqual(d.nostrokeranges[2][1], 0.6)
35 d.excluderange(0.45, 0.55)
36 self.assertEqual(len(d.nostrokeranges), 3)
37 self.assertAlmostEqual(d.nostrokeranges[0][0], 0.1)
38 self.assertAlmostEqual(d.nostrokeranges[0][1], 0.2)
39 self.assertAlmostEqual(d.nostrokeranges[1][0], 0.3)
40 self.assertAlmostEqual(d.nostrokeranges[1][1], 0.4)
41 self.assertAlmostEqual(d.nostrokeranges[2][0], 0.45)
42 self.assertAlmostEqual(d.nostrokeranges[2][1], 0.6)
44 d.excluderange(0.15, 0.25)
45 self.assertEqual(len(d.nostrokeranges), 3)
46 self.assertAlmostEqual(d.nostrokeranges[0][0], 0.1)
47 self.assertAlmostEqual(d.nostrokeranges[0][1], 0.25)
48 self.assertAlmostEqual(d.nostrokeranges[1][0], 0.3)
49 self.assertAlmostEqual(d.nostrokeranges[1][1], 0.4)
50 self.assertAlmostEqual(d.nostrokeranges[2][0], 0.45)
51 self.assertAlmostEqual(d.nostrokeranges[2][1], 0.6)
53 d.excluderange(0.05, 0.15)
54 self.assertEqual(len(d.nostrokeranges), 3)
55 self.assertAlmostEqual(d.nostrokeranges[0][0], 0.05)
56 self.assertAlmostEqual(d.nostrokeranges[0][1], 0.25)
57 self.assertAlmostEqual(d.nostrokeranges[1][0], 0.3)
58 self.assertAlmostEqual(d.nostrokeranges[1][1], 0.4)
59 self.assertAlmostEqual(d.nostrokeranges[2][0], 0.45)
60 self.assertAlmostEqual(d.nostrokeranges[2][1], 0.6)
62 d.excluderange(0.2, 0.35)
63 self.assertEqual(len(d.nostrokeranges), 2)
64 self.assertAlmostEqual(d.nostrokeranges[0][0], 0.05)
65 self.assertAlmostEqual(d.nostrokeranges[0][1], 0.4)
66 self.assertAlmostEqual(d.nostrokeranges[1][0], 0.45)
67 self.assertAlmostEqual(d.nostrokeranges[1][1], 0.6)
69 d.excluderange(0.35, 0.65)
70 self.assertEqual(len(d.nostrokeranges), 1)
71 self.assertAlmostEqual(d.nostrokeranges[0][0], 0.05)
72 self.assertAlmostEqual(d.nostrokeranges[0][1], 0.65)
75 if __name__ == "__main__":
76 unittest.main()