From 50764d9ebbea4cd15717e49ba4ef4f467254a2be Mon Sep 17 00:00:00 2001 From: Andras Tim Date: Fri, 21 Jul 2017 21:27:48 +0200 Subject: [PATCH] Avoid interactive pdb when pytest tests itself - fix #2023 The debugging.py calls post_mortem() on error and pdb will drops an interactive debugger when the stdin is a readable fd. --- _pytest/pytester.py | 7 +++++-- changelog/2023.bugfix | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelog/2023.bugfix diff --git a/_pytest/pytester.py b/_pytest/pytester.py index 1783c9c0c..674adca94 100644 --- a/_pytest/pytester.py +++ b/_pytest/pytester.py @@ -916,8 +916,11 @@ class Testdir: 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. diff --git a/changelog/2023.bugfix b/changelog/2023.bugfix new file mode 100644 index 000000000..acf4b405b --- /dev/null +++ b/changelog/2023.bugfix @@ -0,0 +1 @@ +Set ``stdin`` to a closed ``PIPE`` in ``pytester.py.Testdir.popen()`` for avoid unwanted interactive ``pdb``