-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest-ah2.py
38 lines (32 loc) · 931 Bytes
/
test-ah2.py
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
from ah import Autohighlight
from cStringIO import StringIO
import unittest
test1file = \
"""
{
} {
document : document statement ';' .
document : .
statement : 'foo' .
} {
}
"""
class AhTestContexts(unittest.TestCase):
ourTests = [ [ "statement", ['\\;|', '\\;'] ], \
[ "'foo'", ['\\;|', '\\;'] ] \
]
def setUp(self):
global test1file
self.ah = Autohighlight(StringIO(test1file))
self.ah.parse()
def checkContext(self,number):
sym = self.ourTests[number][0]
res = self.ourTests[number][1:]
context = self.ah.GlobalSymbolDict[sym].get_context(self.ah.GlobalSymbolDict)
self.assertEqual(res, context, "Contexts for %s are not as expected:\n%s\n%s" % (sym,res,context))
def test0(self):
self.checkContext(0)
def test1(self):
self.checkContext(1)
if __name__ == "__main__":
unittest.main()