|
6 | 6 | import platform |
7 | 7 | import sys |
8 | 8 |
|
| 9 | +import six |
| 10 | + |
9 | 11 | import _pytest._code |
10 | 12 | import pytest |
11 | 13 | from _pytest.debugging import _validate_usepdb_cls |
@@ -395,7 +397,7 @@ def test_1(): |
395 | 397 | child = testdir.spawn_pytest(str(p1)) |
396 | 398 | child.expect("test_1") |
397 | 399 | child.expect("Pdb") |
398 | | - child.sendeof() |
| 400 | + child.sendline("q") |
399 | 401 | rest = child.read().decode("utf8") |
400 | 402 | assert "no tests ran" in rest |
401 | 403 | assert "reading from stdin while output" not in rest |
@@ -957,7 +959,7 @@ def test_1(): |
957 | 959 | child = testdir.spawn_pytest(str(p1)) |
958 | 960 | child.expect("test_1") |
959 | 961 | child.expect("Pdb") |
960 | | - child.sendeof() |
| 962 | + child.sendline("quit") |
961 | 963 | rest = child.read().decode("utf8") |
962 | 964 | assert "Quitting debugger" in rest |
963 | 965 | assert "reading from stdin while output" not in rest |
@@ -1163,3 +1165,29 @@ def runcall(self, *args, **kwds): |
1163 | 1165 | ) |
1164 | 1166 | assert result.ret == 0 |
1165 | 1167 | result.stdout.fnmatch_lines(["*runcall_called*", "* 1 passed in *"]) |
| 1168 | + |
| 1169 | + |
| 1170 | +def test_raises_bdbquit_with_eoferror(testdir): |
| 1171 | + """It is not guaranteed that DontReadFromInput's read is called.""" |
| 1172 | + if six.PY2: |
| 1173 | + builtin_module = "__builtin__" |
| 1174 | + input_func = "raw_input" |
| 1175 | + else: |
| 1176 | + builtin_module = "builtins" |
| 1177 | + input_func = "input" |
| 1178 | + p1 = testdir.makepyfile( |
| 1179 | + """ |
| 1180 | + def input_without_read(*args, **kwargs): |
| 1181 | + raise EOFError() |
| 1182 | +
|
| 1183 | + def test(monkeypatch): |
| 1184 | + import {builtin_module} |
| 1185 | + monkeypatch.setattr({builtin_module}, {input_func!r}, input_without_read) |
| 1186 | + __import__('pdb').set_trace() |
| 1187 | + """.format( |
| 1188 | + builtin_module=builtin_module, input_func=input_func |
| 1189 | + ) |
| 1190 | + ) |
| 1191 | + result = testdir.runpytest(str(p1)) |
| 1192 | + result.stdout.fnmatch_lines(["E *BdbQuit", "*= 1 failed in*"]) |
| 1193 | + assert result.ret == 1 |
0 commit comments