summaryrefslogtreecommitdiff
path: root/test/test_python_traceback.vader
blob: 6a659986bb897f4bf42f8560220dbd5ac11acbba (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Execute(ale#python#HandleTraceback returns empty List for empty lines):
  AssertEqual
  \  [],
  \  ale#python#HandleTraceback([], 10)

Execute(ale#python#HandleTraceback returns traceback, when present):
  AssertEqual
  \  [{
  \    'lnum': 1,
  \    'text': 'Exception: Example error (See :ALEDetail)',
  \    'detail': join([
  \      'Traceback (most recent call last):',
  \      '  File "./example.py", line 5, in <module>',
  \      '    raise Exception(''Example message'')',
  \      'Exception: Example error',
  \    ], "\n"),
  \  }],
  \  ale#python#HandleTraceback([
  \    'Traceback (most recent call last):',
  \    '  File "./example.py", line 5, in <module>',
  \    '    raise Exception(''Example message'')',
  \    'Exception: Example error',
  \  ], 1)

" SyntaxError has extra output lines about the source
Execute(ale#python#HandleTraceback returns SyntaxError traceback):
  AssertEqual
  \  [{
  \    'lnum': 1,
  \    'text': 'SyntaxError: invalid syntax (See :ALEDetail)',
  \    'detail': join([
  \      'Traceback (most recent call last):',
  \      '  File "<string>", line 1, in <module>',
  \      '  File "example.py", line 5',
  \      '    +',
  \      '    ^',
  \      'SyntaxError: invalid syntax',
  \    ], "\n"),
  \  }],
  \  ale#python#HandleTraceback([
  \    'Traceback (most recent call last):',
  \    '  File "<string>", line 1, in <module>',
  \    '  File "example.py", line 5',
  \    '    +',
  \    '    ^',
  \    'SyntaxError: invalid syntax',
  \  ], 1)

Execute(ale#python#HandleTraceback ignores traceback after line limit):
  AssertEqual
  \  [],
  \  ale#python#HandleTraceback([
  \    '',
  \    'Traceback (most recent call last):',
  \    '  File "./example.py", line 5, in <module>',
  \    '    raise Exception(''Example message'')',
  \    'Exception: Example error',
  \  ], 1)

Execute(ale#python#HandleTraceback doesn't include later lines in detail):
  AssertEqual
  \  [{
  \    'lnum': 1,
  \    'text': 'Exception: Example error (See :ALEDetail)',
  \    'detail': join([
  \      'Traceback (most recent call last):',
  \      '  File "./example.py", line 5, in <module>',
  \      '    raise Exception(''Example message'')',
  \      'Exception: Example error',
  \    ], "\n"),
  \  }],
  \  ale#python#HandleTraceback([
  \    'Traceback (most recent call last):',
  \    '  File "./example.py", line 5, in <module>',
  \    '    raise Exception(''Example message'')',
  \    'Exception: Example error',
  \    'file:1:2: Style issue',
  \    'file:3:4: Non-style issue',
  \  ], 1)