Skip to content

Commit baf7d3b

Browse files
committed
Convert test_next.py
1 parent 677c7de commit baf7d3b

2 files changed

Lines changed: 84 additions & 84 deletions

File tree

test/functional/test-next.py

Lines changed: 0 additions & 84 deletions
This file was deleted.

test/functional/test_next.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
"""
2+
Functional test of debugger "next" command.
3+
"""
4+
import unittest
5+
from test.functional.fn_helper import compare_output, strarray_setup
6+
7+
8+
class TestNext(unittest.TestCase):
9+
print("test ", __file__, "skipped")
10+
11+
def test_next_same_level(self):
12+
# See that we can next with parameter which is the same as 'next 1'
13+
cmds = ["next", "continue"]
14+
d = strarray_setup(cmds)
15+
d.core.start()
16+
x = 5
17+
y = 6
18+
d.core.stop()
19+
out = ["-- x = 5", "-- y = 6"]
20+
compare_output(self, out, d)
21+
22+
# See that we can next with a computed count value
23+
cmds = ["next 5-3", "continue"]
24+
d = strarray_setup(cmds)
25+
d.core.start()
26+
x = 5 # NOQA
27+
y = 6 # NOQA
28+
z = 7 # NOQA
29+
d.core.stop(options={"remove": True})
30+
out = ["-- x = 5 # NOQA", "-- z = 7 # NOQA"]
31+
compare_output(self, out, d)
32+
return
33+
34+
def test_next_between_fn(self):
35+
# Next over a function
36+
def fact(x):
37+
if x <= 1:
38+
return 1
39+
return fact(x - 1)
40+
41+
cmds = ["next", "continue"]
42+
d = strarray_setup(cmds)
43+
d.core.start()
44+
x = fact(4) # NOQA
45+
y = 5 # NOQA
46+
d.core.stop(options={"remove": True})
47+
out = ["-- x = fact(4) # NOQA", "-- y = 5 # NOQA"]
48+
compare_output(self, out, d)
49+
return
50+
51+
def test_next_in_exception(self):
52+
return
53+
54+
def boom(x):
55+
y = 0 / x # NOQA
56+
return
57+
58+
def buggy_fact(x):
59+
if x <= 1:
60+
return boom(0)
61+
return buggy_fact(x - 1)
62+
63+
cmds = ["next", "continue"]
64+
d = strarray_setup(cmds)
65+
try:
66+
d.core.start()
67+
x = buggy_fact(4) # NOQA
68+
y = 5 # NOQA
69+
self.assertTrue(False, "should have raised an exception")
70+
except ZeroDivisionError:
71+
self.assertTrue(True, "Got the exception")
72+
finally:
73+
d.core.stop(options={"remove": True})
74+
pass
75+
76+
out = ["-- x = buggy_fact(4) # NOQA", "!! x = buggy_fact(4) # NOQA"]
77+
compare_output(self, out, d, cmds)
78+
return
79+
80+
pass
81+
82+
83+
if __name__ == "__main__":
84+
unittest.main()

0 commit comments

Comments
 (0)