diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2011-12-08 22:14:56 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2011-12-08 22:14:56 -0500 |
commit | 77cd2585509a9d9b5a4050464548d79f882f410c (patch) | |
tree | d678936e10c13763dd4befea082536f2f5665b60 | |
parent | 2bc1e8fbf2c5be55e1f186d956121bc26eee40c5 (diff) | |
download | cpython-git-77cd2585509a9d9b5a4050464548d79f882f410c.tar.gz |
Implemented suggested improvements for pdb test by Éric Araujo
-rw-r--r-- | Lib/test/test_pdb.py | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 5b1f8f792a..5a9091f795 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -280,35 +280,36 @@ def test_pdb_continue_in_bottomframe(): 4 """ -class Tester7750(unittest.TestCase): - # if the filename has something that resolves to a python - # escape character (such as \t), it will fail - test_fn = '.\\test7750.py' - - msg = "issue7750 only applies when os.sep is a backslash" - @unittest.skipUnless(os.path.sep == '\\', msg) - def test_issue7750(self): - with open(self.test_fn, 'w') as f: - f.write('print("hello world")') - cmd = [sys.executable, '-m', 'pdb', self.test_fn,] +class ModuleInitTester(unittest.TestCase): + + def test_filename_correct(self): + """ + In issue 7750, it was found that if the filename has a sequence that + resolves to an escape character in a Python string (such as \t), it + will be treated as the escaped character. + """ + # the test_fn must contain something like \t + # on Windows, this will create 'test_mod.py' in the current directory. + # 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, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, ) stdout, stderr = proc.communicate('quit\n') - self.assertNotIn('IOError', stdout, "pdb munged the filename") - - def tearDown(self): - if os.path.isfile(self.test_fn): - os.remove(self.test_fn) + self.assertIn(code, stdout, "pdb munged the filename") def test_main(): from test import test_pdb test_support.run_doctest(test_pdb, verbosity=True) - + test_support.run_unittest(ModuleInitTester) if __name__ == '__main__': test_main() - unittest.main() |