mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Fix for bug 4362 "FileIO object in io module"; Patch by amaury.forgeotdarc.
This commit is contained in:
parent
91cc8fb92b
commit
40e8246f6a
2 changed files with 47 additions and 10 deletions
|
@ -1249,6 +1249,9 @@ class TextIOWrapperTest(unittest.TestCase):
|
|||
|
||||
class MiscIOTest(unittest.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
support.unlink(support.TESTFN)
|
||||
|
||||
def testImport__all__(self):
|
||||
for name in io.__all__:
|
||||
obj = getattr(io, name, None)
|
||||
|
@ -1261,6 +1264,34 @@ class MiscIOTest(unittest.TestCase):
|
|||
self.assert_(issubclass(obj, io.IOBase))
|
||||
|
||||
|
||||
def test_attributes(self):
|
||||
f = io.open(support.TESTFN, "wb", buffering=0)
|
||||
self.assertEquals(f.mode, "w")
|
||||
f.close()
|
||||
|
||||
f = io.open(support.TESTFN, "U")
|
||||
self.assertEquals(f.name, support.TESTFN)
|
||||
self.assertEquals(f.buffer.name, support.TESTFN)
|
||||
self.assertEquals(f.buffer.raw.name, support.TESTFN)
|
||||
self.assertEquals(f.mode, "U")
|
||||
self.assertEquals(f.buffer.mode, "r")
|
||||
self.assertEquals(f.buffer.raw.mode, "r")
|
||||
f.close()
|
||||
|
||||
f = io.open(support.TESTFN, "w+")
|
||||
self.assertEquals(f.mode, "w+")
|
||||
self.assertEquals(f.buffer.mode, "r+") # Does it really matter?
|
||||
self.assertEquals(f.buffer.raw.mode, "r+")
|
||||
|
||||
g = io.open(f.fileno(), "wb", closefd=False)
|
||||
self.assertEquals(g.mode, "w")
|
||||
self.assertEquals(g.raw.mode, "w")
|
||||
self.assertEquals(g.name, f.fileno())
|
||||
self.assertEquals(g.raw.name, f.fileno())
|
||||
f.close()
|
||||
g.close()
|
||||
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(IOTest, BytesIOTest, StringIOTest,
|
||||
BufferedReaderTest, BufferedWriterTest,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue