Kaydet (Commit) 77cd2585 authored tarafından Jason R. Coombs's avatar Jason R. Coombs

Implemented suggested improvements for pdb test by Éric Araujo

üst 2bc1e8fb
...@@ -280,35 +280,36 @@ def test_pdb_continue_in_bottomframe(): ...@@ -280,35 +280,36 @@ def test_pdb_continue_in_bottomframe():
4 4
""" """
class Tester7750(unittest.TestCase): class ModuleInitTester(unittest.TestCase):
# if the filename has something that resolves to a python
# escape character (such as \t), it will fail def test_filename_correct(self):
test_fn = '.\\test7750.py' """
In issue 7750, it was found that if the filename has a sequence that
msg = "issue7750 only applies when os.sep is a backslash" resolves to an escape character in a Python string (such as \t), it
@unittest.skipUnless(os.path.sep == '\\', msg) will be treated as the escaped character.
def test_issue7750(self): """
with open(self.test_fn, 'w') as f: # the test_fn must contain something like \t
f.write('print("hello world")') # on Windows, this will create 'test_mod.py' in the current directory.
cmd = [sys.executable, '-m', 'pdb', self.test_fn,] # on Unix, this will create '.\test_mod.py' in the current directory.
test_fn = '.\\test_mod.py'
code = 'print("testing pdb")'
with open(test_fn, 'w') as f:
f.write(code)
self.addCleanup(os.remove, test_fn)
cmd = [sys.executable, '-m', 'pdb', test_fn,]
proc = subprocess.Popen(cmd, proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
) )
stdout, stderr = proc.communicate('quit\n') stdout, stderr = proc.communicate('quit\n')
self.assertNotIn('IOError', stdout, "pdb munged the filename") self.assertIn(code, stdout, "pdb munged the filename")
def tearDown(self):
if os.path.isfile(self.test_fn):
os.remove(self.test_fn)
def test_main(): def test_main():
from test import test_pdb from test import test_pdb
test_support.run_doctest(test_pdb, verbosity=True) test_support.run_doctest(test_pdb, verbosity=True)
test_support.run_unittest(ModuleInitTester)
if __name__ == '__main__': if __name__ == '__main__':
test_main() test_main()
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment