test_error_colno.py (658B)
1 import WebIDL 2 3 4 def WebIDLTest(parser, harness): 5 # Check that error messages put the '^' in the right place. 6 7 threw = False 8 input = "interface ?" 9 try: 10 parser.parse(input) 11 parser.finish() 12 except WebIDL.WebIDLError as e: 13 threw = True 14 lines = str(e).split("\n") 15 16 harness.check(len(lines), 3, "Expected number of lines in error message") 17 harness.check(lines[1], input, "Second line shows error") 18 harness.check( 19 lines[2], 20 " " * (len(input) - 1) + "^", 21 "Correct column pointer in error message", 22 ) 23 24 harness.ok(threw, "Should have thrown.")