diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-03-12 01:17:02 +0200 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-03-12 01:17:02 +0200 |
commit | 11f8b6872a779b6b03fc070ad64ed778c835435a (patch) | |
tree | c6eabf7b222c7bcb0093f0eaac4aec0639f75df2 /Lib/test/test_file2k.py | |
parent | f60845b70a78c0e29dc0e865c6cd9e2e35e635f5 (diff) | |
download | cpython-git-11f8b6872a779b6b03fc070ad64ed778c835435a.tar.gz |
#14161: fix the __repr__ of file objects to escape the file name.
Diffstat (limited to 'Lib/test/test_file2k.py')
-rw-r--r-- | Lib/test/test_file2k.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py index 399f119b81..0c892bd2ba 100644 --- a/Lib/test/test_file2k.py +++ b/Lib/test/test_file2k.py @@ -89,6 +89,13 @@ class AutoFileTests(unittest.TestCase): def testRepr(self): # verify repr works self.assertTrue(repr(self.f).startswith("<open file '" + TESTFN)) + # see issue #14161 + # Windows doesn't like \r\n\t" in the file name, but ' is ok + fname = 'xx\rxx\nxx\'xx"xx' if sys.platform != "win32" else "xx'xx" + with open(fname, 'w') as f: + self.addCleanup(os.remove, fname) + self.assertTrue(repr(f).startswith( + "<open file %r, mode 'w' at" % fname)) def testErrors(self): self.f.close() |