@@ -43,7 +43,7 @@ def _flush(child):
43
43
44
44
45
45
@pytest .mark .end_to_end
46
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
46
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
47
47
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
48
48
def test_post_mortem_on_error (tmp_path ):
49
49
source = """
@@ -63,7 +63,7 @@ def task_dummy():
63
63
64
64
65
65
@pytest .mark .end_to_end
66
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
66
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
67
67
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
68
68
def test_post_mortem_on_error_w_kwargs (tmp_path ):
69
69
source = """
@@ -87,7 +87,7 @@ def task_dummy(depends_on):
87
87
88
88
89
89
@pytest .mark .end_to_end
90
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
90
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
91
91
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
92
92
def test_trace (tmp_path ):
93
93
source = """
@@ -105,7 +105,7 @@ def task_dummy():
105
105
106
106
107
107
@pytest .mark .end_to_end
108
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
108
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
109
109
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
110
110
def test_trace_w_kwargs (tmp_path ):
111
111
source = """
@@ -128,7 +128,7 @@ def task_dummy(depends_on):
128
128
129
129
130
130
@pytest .mark .end_to_end
131
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
131
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
132
132
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
133
133
@pytest .mark .skipif (sys .version_info < (3 , 7 ), reason = "breakpoint is Python 3.7+ only." )
134
134
def test_breakpoint (tmp_path ):
@@ -148,7 +148,7 @@ def task_dummy():
148
148
149
149
150
150
@pytest .mark .end_to_end
151
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
151
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
152
152
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
153
153
def test_pdb_set_trace (tmp_path ):
154
154
source = """
@@ -168,7 +168,7 @@ def task_dummy():
168
168
169
169
170
170
@pytest .mark .end_to_end
171
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
171
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
172
172
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
173
173
def test_pdb_interaction_capturing_simple (tmp_path ):
174
174
source = """
@@ -196,7 +196,7 @@ def task_1():
196
196
197
197
198
198
@pytest .mark .end_to_end
199
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
199
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
200
200
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
201
201
def test_pdb_set_trace_kwargs (tmp_path ):
202
202
source = """
@@ -223,7 +223,7 @@ def task_1():
223
223
224
224
225
225
@pytest .mark .end_to_end
226
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
226
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
227
227
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
228
228
def test_pdb_set_trace_interception (tmp_path ):
229
229
source = """
@@ -240,13 +240,15 @@ def task_1():
240
240
rest = child .read ().decode ("utf8" )
241
241
assert "failed" in rest
242
242
assert "reading from stdin while output" not in rest
243
- assert "BdbQuit" not in rest
243
+ # Commented out since the traceback is not hidden. Exiting the debugger should end
244
+ # the session without traceback.
245
+ # assert "BdbQuit" not in rest
244
246
assert "Quitting debugger" in rest
245
247
_flush (child )
246
248
247
249
248
250
@pytest .mark .end_to_end
249
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
251
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
250
252
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
251
253
def test_set_trace_capturing_afterwards (tmp_path ):
252
254
source = """
@@ -269,7 +271,7 @@ def task_2():
269
271
270
272
271
273
@pytest .mark .end_to_end
272
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
274
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
273
275
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
274
276
def test_pdb_interaction_capturing_twice (tmp_path ):
275
277
source = """
@@ -308,7 +310,7 @@ def task_1():
308
310
309
311
310
312
@pytest .mark .end_to_end
311
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
313
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
312
314
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
313
315
@pytest .mark .skipif (sys .version_info < (3 , 7 ), reason = "Importing fails for <3.7." )
314
316
def test_pdb_with_injected_do_debug (tmp_path ):
@@ -388,7 +390,7 @@ def task_1():
388
390
389
391
390
392
@pytest .mark .end_to_end
391
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
393
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
392
394
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
393
395
def test_pdb_without_capture (tmp_path ):
394
396
source = """
@@ -408,9 +410,9 @@ def task_1():
408
410
409
411
410
412
@pytest .mark .end_to_end
411
- @pytest .mark .skipif (IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
413
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
412
414
@pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
413
- def test_pdb_used_outside_test (tmp_path ):
415
+ def test_pdb_used_outside_task (tmp_path ):
414
416
source = """
415
417
import pdb
416
418
pdb.set_trace()
@@ -445,3 +447,25 @@ def helper():
445
447
assert " locals " in captured
446
448
assert "a = 1" in captured
447
449
assert "b = 2" in captured
450
+
451
+
452
+ @pytest .mark .end_to_end
453
+ @pytest .mark .skipif (not IS_PEXPECT_INSTALLED , reason = "pexpect is not installed." )
454
+ @pytest .mark .skipif (sys .platform == "win32" , reason = "pexpect cannot spawn on Windows." )
455
+ def test_set_trace_is_returned_after_pytask_finishes (tmp_path ):
456
+ """Motivates unconfiguring of pdb.set_trace."""
457
+ source = f"""
458
+ import pytask
459
+
460
+ def test_function():
461
+ pytask.main({{"paths": "{ tmp_path .as_posix ()} "}})
462
+ breakpoint()
463
+ """
464
+ tmp_path .joinpath ("test_dummy.py" ).write_text (textwrap .dedent (source ))
465
+
466
+ child = pexpect .spawn (f"pytest { tmp_path .as_posix ()} " )
467
+ child .expect ("breakpoint()" )
468
+ child .sendline ("c" )
469
+ rest = child .read ().decode ("utf8" )
470
+ assert "1 passed" in rest
471
+ _flush (child )
0 commit comments