Jason R. Coombs committed 70337a6

Implemented suggested improvements for pdb test by Éric Araujo

Comments (0)

Files changed (1)


-class Tester7750(unittest.TestCase):
-    # if the filename has something that resolves to a python
-    #  escape character (such as \t), it will fail
-    test_fn = '.\\'
+class ModuleInitTester(unittest.TestCase):
-    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,]
+    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 '' in the current directory.
+        # on Unix, this will create '.\' in the current directory.
+        test_fn = '.\\'
+        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, 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__':
-    unittest.main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.