mirror of https://github.com/python/cpython.git
bpo-45208: Make test_pdb.test_checkline_is_not_executable() quiet (GH-28354)
test_pdb.test_checkline_is_not_executable() no longer writes output to stdout. Remove also unused variables 'f'.
This commit is contained in:
parent
764e6823a7
commit
e08e491a6c
|
@ -11,7 +11,7 @@
|
||||||
import textwrap
|
import textwrap
|
||||||
import linecache
|
import linecache
|
||||||
|
|
||||||
from contextlib import ExitStack
|
from contextlib import ExitStack, redirect_stdout
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from test.support import os_helper
|
from test.support import os_helper
|
||||||
# This little helper class is essential for testing pdb under doctest.
|
# This little helper class is essential for testing pdb under doctest.
|
||||||
|
@ -1733,7 +1733,7 @@ def test_module_without_a_main(self):
|
||||||
os_helper.rmtree(module_name)
|
os_helper.rmtree(module_name)
|
||||||
init_file = module_name + '/__init__.py'
|
init_file = module_name + '/__init__.py'
|
||||||
os.mkdir(module_name)
|
os.mkdir(module_name)
|
||||||
with open(init_file, 'w') as f:
|
with open(init_file, 'w'):
|
||||||
pass
|
pass
|
||||||
self.addCleanup(os_helper.rmtree, module_name)
|
self.addCleanup(os_helper.rmtree, module_name)
|
||||||
stdout, stderr = self._run_pdb(['-m', module_name], "")
|
stdout, stderr = self._run_pdb(['-m', module_name], "")
|
||||||
|
@ -1746,7 +1746,7 @@ def test_package_without_a_main(self):
|
||||||
os_helper.rmtree(pkg_name)
|
os_helper.rmtree(pkg_name)
|
||||||
modpath = pkg_name + '/' + module_name
|
modpath = pkg_name + '/' + module_name
|
||||||
os.makedirs(modpath)
|
os.makedirs(modpath)
|
||||||
with open(modpath + '/__init__.py', 'w') as f:
|
with open(modpath + '/__init__.py', 'w'):
|
||||||
pass
|
pass
|
||||||
self.addCleanup(os_helper.rmtree, pkg_name)
|
self.addCleanup(os_helper.rmtree, pkg_name)
|
||||||
stdout, stderr = self._run_pdb(['-m', modpath.replace('/', '.')], "")
|
stdout, stderr = self._run_pdb(['-m', modpath.replace('/', '.')], "")
|
||||||
|
@ -1960,19 +1960,20 @@ def test_checkline_after_reset(self):
|
||||||
self.assertEqual(db.checkline(os_helper.TESTFN, 1), 1)
|
self.assertEqual(db.checkline(os_helper.TESTFN, 1), 1)
|
||||||
|
|
||||||
def test_checkline_is_not_executable(self):
|
def test_checkline_is_not_executable(self):
|
||||||
with open(os_helper.TESTFN, "w") as f:
|
# Test for comments, docstrings and empty lines
|
||||||
# Test for comments, docstrings and empty lines
|
s = textwrap.dedent("""
|
||||||
s = textwrap.dedent("""
|
# Comment
|
||||||
# Comment
|
\"\"\" docstring \"\"\"
|
||||||
\"\"\" docstring \"\"\"
|
''' docstring '''
|
||||||
''' docstring '''
|
|
||||||
|
|
||||||
""")
|
""")
|
||||||
|
with open(os_helper.TESTFN, "w") as f:
|
||||||
f.write(s)
|
f.write(s)
|
||||||
db = pdb.Pdb()
|
|
||||||
num_lines = len(s.splitlines()) + 2 # Test for EOF
|
num_lines = len(s.splitlines()) + 2 # Test for EOF
|
||||||
for lineno in range(num_lines):
|
with redirect_stdout(StringIO()):
|
||||||
self.assertFalse(db.checkline(os_helper.TESTFN, lineno))
|
db = pdb.Pdb()
|
||||||
|
for lineno in range(num_lines):
|
||||||
|
self.assertFalse(db.checkline(os_helper.TESTFN, lineno))
|
||||||
|
|
||||||
|
|
||||||
def load_tests(loader, tests, pattern):
|
def load_tests(loader, tests, pattern):
|
||||||
|
|
Loading…
Reference in New Issue