Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6cccb86

Browse files
committed
#7964 followup: add test case to ensure issue remains fixed.
1 parent 4e95457 commit 6cccb86

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lib/test/test_pdb.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# A test suite for pdb; not very comprehensive at the moment.
22

33
import imp
4+
import pdb
45
import sys
6+
import unittest
7+
import subprocess
58

69
from test import support
710
# This little helper class is essential for testing pdb under doctest.
@@ -286,9 +289,30 @@ def test_pdb_run_with_code_object():
286289
"""
287290

288291

292+
class PdbTestCase(unittest.TestCase):
293+
294+
def test_issue7964(self):
295+
# open the file as binary so we can force \r\n newline
296+
with open(support.TESTFN, 'wb') as f:
297+
f.write(b'print("testing my pdb")\r\n')
298+
cmd = [sys.executable, '-m', 'pdb', support.TESTFN]
299+
proc = subprocess.Popen(cmd,
300+
stdout=subprocess.PIPE,
301+
stdin=subprocess.PIPE,
302+
stderr=subprocess.STDOUT,
303+
)
304+
stdout, stderr = proc.communicate(b'quit\n')
305+
self.assertNotIn(b'SyntaxError', stdout,
306+
"Got a syntax error running test script under PDB")
307+
308+
def tearDown(self):
309+
support.unlink(support.TESTFN)
310+
311+
289312
def test_main():
290313
from test import test_pdb
291314
support.run_doctest(test_pdb, verbosity=True)
315+
support.run_unittest(PdbTestCase)
292316

293317

294318
if __name__ == '__main__':

0 commit comments

Comments
 (0)