mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
bpo-45208: Make test_pdb.test_checkline_is_not_executable() quiet (GH-28354) (GH-28381)
test_pdb.test_checkline_is_not_executable() no longer writes output
to stdout.
Remove also unused variables 'f'.
(cherry picked from commit e08e491a6c)
This commit is contained in:
parent
9443ce4eed
commit
471b3811fe
1 changed files with 14 additions and 13 deletions
|
|
@ -11,7 +11,7 @@ import subprocess
|
|||
import textwrap
|
||||
import linecache
|
||||
|
||||
from contextlib import ExitStack
|
||||
from contextlib import ExitStack, redirect_stdout
|
||||
from io import StringIO
|
||||
from test import support
|
||||
# This little helper class is essential for testing pdb under doctest.
|
||||
|
|
@ -1625,7 +1625,7 @@ def bœr():
|
|||
support.rmtree(module_name)
|
||||
init_file = module_name + '/__init__.py'
|
||||
os.mkdir(module_name)
|
||||
with open(init_file, 'w') as f:
|
||||
with open(init_file, 'w'):
|
||||
pass
|
||||
self.addCleanup(support.rmtree, module_name)
|
||||
stdout, stderr = self._run_pdb(['-m', module_name], "")
|
||||
|
|
@ -1638,7 +1638,7 @@ def bœr():
|
|||
support.rmtree(pkg_name)
|
||||
modpath = pkg_name + '/' + module_name
|
||||
os.makedirs(modpath)
|
||||
with open(modpath + '/__init__.py', 'w') as f:
|
||||
with open(modpath + '/__init__.py', 'w'):
|
||||
pass
|
||||
self.addCleanup(support.rmtree, pkg_name)
|
||||
stdout, stderr = self._run_pdb(['-m', modpath.replace('/', '.')], "")
|
||||
|
|
@ -1851,19 +1851,20 @@ class ChecklineTests(unittest.TestCase):
|
|||
self.assertEqual(db.checkline(support.TESTFN, 1), 1)
|
||||
|
||||
def test_checkline_is_not_executable(self):
|
||||
with open(support.TESTFN, "w") as f:
|
||||
# Test for comments, docstrings and empty lines
|
||||
s = textwrap.dedent("""
|
||||
# Comment
|
||||
\"\"\" docstring \"\"\"
|
||||
''' docstring '''
|
||||
# Test for comments, docstrings and empty lines
|
||||
s = textwrap.dedent("""
|
||||
# Comment
|
||||
\"\"\" docstring \"\"\"
|
||||
''' docstring '''
|
||||
|
||||
""")
|
||||
""")
|
||||
with open(support.TESTFN, "w") as f:
|
||||
f.write(s)
|
||||
db = pdb.Pdb()
|
||||
num_lines = len(s.splitlines()) + 2 # Test for EOF
|
||||
for lineno in range(num_lines):
|
||||
self.assertFalse(db.checkline(support.TESTFN, lineno))
|
||||
with redirect_stdout(StringIO()):
|
||||
db = pdb.Pdb()
|
||||
for lineno in range(num_lines):
|
||||
self.assertFalse(db.checkline(support.TESTFN, lineno))
|
||||
|
||||
|
||||
def load_tests(*args):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue