##// END OF EJS Templates
Fix some tests on Python 3.13 RC1 (#14504)...
M Bussonnier -
r28829:82eba444 merge
parent child Browse files
Show More
@@ -59,40 +59,43 b' def test_ipdb_magics():'
59
59
60 First, set up some test functions and classes which we can inspect.
60 First, set up some test functions and classes which we can inspect.
61
61
62 >>> class ExampleClass(object):
62 In [1]: class ExampleClass(object):
63 ... """Docstring for ExampleClass."""
63 ...: """Docstring for ExampleClass."""
64 ... def __init__(self):
64 ...: def __init__(self):
65 ... """Docstring for ExampleClass.__init__"""
65 ...: """Docstring for ExampleClass.__init__"""
66 ... pass
66 ...: pass
67 ... def __str__(self):
67 ...: def __str__(self):
68 ... return "ExampleClass()"
68 ...: return "ExampleClass()"
69
70 >>> def example_function(x, y, z="hello"):
71 ... """Docstring for example_function."""
72 ... pass
73
69
74 >>> old_trace = sys.gettrace()
70 In [2]: def example_function(x, y, z="hello"):
71 ...: """Docstring for example_function."""
72 ...: pass
75
73
76 Create a function which triggers ipdb.
74 In [3]: old_trace = sys.gettrace()
77
75
78 >>> def trigger_ipdb():
76 Create a function which triggers ipdb.
79 ... a = ExampleClass()
80 ... debugger.Pdb().set_trace()
81
77
82 >>> with PdbTestInput([
78 In [4]: def trigger_ipdb():
83 ... 'pdef example_function',
79 ...: a = ExampleClass()
84 ... 'pdoc ExampleClass',
80 ...: debugger.Pdb().set_trace()
85 ... 'up',
81
86 ... 'down',
82 Run ipdb with faked input & check output. Because of a difference between
87 ... 'list',
83 Python 3.13 & older versions, the first bit of the output is inconsistent.
88 ... 'pinfo a',
84 We need to use ... to accommodate that, so the examples have to use IPython
89 ... 'll',
85 prompts so that ... is distinct from the Python PS2 prompt.
90 ... 'continue',
86
91 ... ]):
87 In [5]: with PdbTestInput([
92 ... trigger_ipdb()
88 ...: 'pdef example_function',
93 --Return--
89 ...: 'pdoc ExampleClass',
94 None
90 ...: 'up',
95 > <doctest ...>(3)trigger_ipdb()
91 ...: 'down',
92 ...: 'list',
93 ...: 'pinfo a',
94 ...: 'll',
95 ...: 'continue',
96 ...: ]):
97 ...: trigger_ipdb()
98 ...> <doctest ...>(3)trigger_ipdb()
96 1 def trigger_ipdb():
99 1 def trigger_ipdb():
97 2 a = ExampleClass()
100 2 a = ExampleClass()
98 ----> 3 debugger.Pdb().set_trace()
101 ----> 3 debugger.Pdb().set_trace()
@@ -112,8 +115,7 b' def test_ipdb_magics():'
112 10 ]):
115 10 ]):
113 ---> 11 trigger_ipdb()
116 ---> 11 trigger_ipdb()
114 <BLANKLINE>
117 <BLANKLINE>
115 ipdb> down
118 ipdb> down...
116 None
117 > <doctest ...>(3)trigger_ipdb()
119 > <doctest ...>(3)trigger_ipdb()
118 1 def trigger_ipdb():
120 1 def trigger_ipdb():
119 2 a = ExampleClass()
121 2 a = ExampleClass()
@@ -136,10 +138,10 b' def test_ipdb_magics():'
136 ----> 3 debugger.Pdb().set_trace()
138 ----> 3 debugger.Pdb().set_trace()
137 <BLANKLINE>
139 <BLANKLINE>
138 ipdb> continue
140 ipdb> continue
139
141
140 Restore previous trace function, e.g. for coverage.py
142 Restore previous trace function, e.g. for coverage.py
141
143
142 >>> sys.settrace(old_trace)
144 In [6]: sys.settrace(old_trace)
143 '''
145 '''
144
146
145 def test_ipdb_magics2():
147 def test_ipdb_magics2():
@@ -495,15 +497,26 b' def test_decorator_skip_with_breakpoint():'
495 child.expect_exact(line)
497 child.expect_exact(line)
496 child.sendline("")
498 child.sendline("")
497
499
498 # as the filename does not exists, we'll rely on the filename prompt
500 # From 3.13, set_trace()/breakpoint() stop on the line where they're
499 child.expect_exact("47 bar(3, 4)")
501 # called, instead of the next line.
500
502 if sys.version_info >= (3, 13):
501 for input_, expected in [
503 child.expect_exact("--> 46 ipdb.set_trace()")
502 (f"b {name}.py:3", ""),
504 extra_step = [("step", "--> 47 bar(3, 4)")]
503 ("step", "1---> 3 pass # should not stop here except"),
505 else:
504 ("step", "---> 38 @pdb_skipped_decorator"),
506 child.expect_exact("--> 47 bar(3, 4)")
505 ("continue", ""),
507 extra_step = []
506 ]:
508
509 for input_, expected in (
510 [
511 (f"b {name}.py:3", ""),
512 ]
513 + extra_step
514 + [
515 ("step", "1---> 3 pass # should not stop here except"),
516 ("step", "---> 38 @pdb_skipped_decorator"),
517 ("continue", ""),
518 ]
519 ):
507 child.expect("ipdb>")
520 child.expect("ipdb>")
508 child.sendline(input_)
521 child.sendline(input_)
509 child.expect_exact(input_)
522 child.expect_exact(input_)
@@ -516,23 +516,23 b' def test_pinfo_docstring_dynamic(capsys):'
516
516
517 ip.run_line_magic("pinfo", "b.prop")
517 ip.run_line_magic("pinfo", "b.prop")
518 captured = capsys.readouterr()
518 captured = capsys.readouterr()
519 assert "Docstring: cdoc for prop" in captured.out
519 assert re.search(r"Docstring:\s+cdoc for prop", captured.out)
520
520
521 ip.run_line_magic("pinfo", "b.non_exist")
521 ip.run_line_magic("pinfo", "b.non_exist")
522 captured = capsys.readouterr()
522 captured = capsys.readouterr()
523 assert "Docstring: cdoc for non_exist" in captured.out
523 assert re.search(r"Docstring:\s+cdoc for non_exist", captured.out)
524
524
525 ip.run_cell("b.prop?")
525 ip.run_cell("b.prop?")
526 captured = capsys.readouterr()
526 captured = capsys.readouterr()
527 assert "Docstring: cdoc for prop" in captured.out
527 assert re.search(r"Docstring:\s+cdoc for prop", captured.out)
528
528
529 ip.run_cell("b.non_exist?")
529 ip.run_cell("b.non_exist?")
530 captured = capsys.readouterr()
530 captured = capsys.readouterr()
531 assert "Docstring: cdoc for non_exist" in captured.out
531 assert re.search(r"Docstring:\s+cdoc for non_exist", captured.out)
532
532
533 ip.run_cell("b.undefined?")
533 ip.run_cell("b.undefined?")
534 captured = capsys.readouterr()
534 captured = capsys.readouterr()
535 assert "Docstring: <no docstring>" in captured.out
535 assert re.search(r"Type:\s+NoneType", captured.out)
536
536
537
537
538 def test_pinfo_magic():
538 def test_pinfo_magic():
General Comments 0
You need to be logged in to leave comments. Login now