Skip to content

Commit

Permalink
Avoid interactive pdb when pytest tests itself - fix pytest-dev#2023
Browse files Browse the repository at this point in the history
The debugging.py calls post_mortem() on error and pdb will drops an
interactive debugger when the stdin is a readable fd.
  • Loading branch information
andras-tim committed Jul 21, 2017
1 parent 3578f4e commit 7d8ff55
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Ahn Ki-Wook
Alexander Johnson
Alexei Kozlenok
Anatoly Bubenkoff
Andras Tim
Andreas Zeidler
Andrzej Ostrowski
Andy Freeland
Expand Down
7 changes: 5 additions & 2 deletions _pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,11 @@ def popen(self, cmdargs, stdout, stderr, **kw):
env['PYTHONPATH'] = os.pathsep.join(filter(None, [
str(os.getcwd()), env.get('PYTHONPATH', '')]))
kw['env'] = env
return subprocess.Popen(cmdargs,
stdout=stdout, stderr=stderr, **kw)

popen = subprocess.Popen(cmdargs, stdin=subprocess.PIPE, stdout=stdout, stderr=stderr, **kw)
popen.stdin.close()

return popen

def run(self, *cmdargs):
"""Run a command with arguments.
Expand Down
1 change: 1 addition & 0 deletions changelog/2023.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set ``stdin`` to a closed ``PIPE`` in ``pytester.py.Testdir.popen()`` for avoid unwanted interactive ``pdb``

0 comments on commit 7d8ff55

Please sign in to comment.