[Python-Dev] [Python-checkins] cpython (2.7): PDB now will properly escape backslashes in the names of modules it executes. (original) (raw)

Jason R. Coombs jaraco at jaraco.com
Tue Dec 6 23:34:07 CET 2011


Éric, These are all good suggestions. I'll make them at some point.

Thanks.

-----Original Message----- From: python-dev-bounces+jaraco=jaraco.com at python.org [mailto:python-_ _dev-bounces+jaraco=jaraco.com at python.org] On Behalf Of Éric Araujo Sent: Friday, 18 November, 2011 10:10 To: python-dev at python.org Subject: Re: [Python-Dev] [Python-checkins] cpython (2.7): PDB now will properly escape backslashes in the names of modules it executes.

Hi Jason, > http://hg.python.org/cpython/rev/f7dd5178f36a > branch: 2.7 > user: Jason R. Coombs <jaraco at jaraco.com> > date: Thu Nov 17 18:03:24 2011 -0500 > summary: > PDB now will properly escape backslashes in the names of modules it > executes. Fixes #7750 > diff --git a/Lib/test/testpdb.py b/Lib/test/testpdb.py > +class Tester7750(unittest.TestCase): I think we have an unwritten rule that test class and method names should tell something about what they test. (We do have things like TestWeirdBugs and test12345, but I don’t think it’s a useful pattern to follow :) Not a big deal anyway. > + # if the filename has something that resolves to a python > + # escape character (such as \t), it will fail > + testfn = '.\test7750.py' > + > + msg = "issue7750 only applies when os.sep is a backslash" > + @unittest.skipUnless(os.path.sep == '\', msg) > + def testissue7750(self): > + with open(self.testfn, 'w') as f: > + f.write('print("hello world")') > + cmd = [sys.executable, '-m', 'pdb', self.testfn,] > + 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") Why not check for assertIn(filename, stdout)? (In other words, check for intended behavior rather than implementation of the erstwhile bug.) BTW, I’ve just tested that giving a message argument to assertNotIn (the third argument), unittest still displays the other arguments to allow for easier debugging. I didn’t know that, it’s cool! > + def tearDown(self): > + if os.path.isfile(self.testfn): > + os.remove(self.testfn) In my own tests, I’ve become fond of using “self.addCleanup(os.remove, filename)”: It’s shorter that a tearDown and is right there on the line that follows or precedes the file creation. > if name == 'main': > testmain() > + unittest.main() This looks strange. Regards


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python- dev/jaraco%40jaraco.com -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 6662 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-dev/attachments/20111206/fb63e257/attachment.bin>



More information about the Python-Dev mailing list