OILS / core / ui_test.py View on Github | oilshell.org

30 lines, 17 significant
1#!/usr/bin/env python2
2from __future__ import print_function
3"""ui_test.py: Tests for ui.py."""
4
5import unittest
6
7from core import test_lib
8from core import ui # module under test
9
10
11class UiTest(unittest.TestCase):
12
13 def testErrorFormatter(self):
14 arena = test_lib.MakeArena('')
15 line_id = arena.AddLine('[line one]', 1)
16 tok1 = arena.NewToken(-1, 0, 2, line_id)
17 tok2 = arena.NewToken(-1, 2, 2, line_id)
18
19 errfmt = ui.ErrorFormatter()
20
21 # no location info
22 errfmt.Print_('hello')
23
24 with ui.ctx_Location(errfmt, tok1):
25 errfmt.Print_('zero')
26 errfmt.Print_('zero', tok2)
27
28
29if __name__ == '__main__':
30 unittest.main()