diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2011-10-31 18:34:46 (GMT) |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2011-10-31 18:34:46 (GMT) |
commit | 59142db6d35f00142cd9982878e75d43cbda7a68 (patch) | |
tree | cf1d1ca5ffda256d0b9fe259c7c5726d3e897482 /Lib/test/test_io.py | |
parent | ab06e3f285ae61e5abc48b350034c94b7d624fda (diff) | |
download | cpython-59142db6d35f00142cd9982878e75d43cbda7a68.zip cpython-59142db6d35f00142cd9982878e75d43cbda7a68.tar.gz cpython-59142db6d35f00142cd9982878e75d43cbda7a68.tar.bz2 |
Issue #12797: Added custom opener parameter to builtin open() and FileIO.open().
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 0debc80..318f7a7 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -621,6 +621,15 @@ class IOTest(unittest.TestCase): for obj in test: self.assertTrue(hasattr(obj, "__dict__")) + def test_opener(self): + with self.open(support.TESTFN, "w") as f: + f.write("egg\n") + fd = os.open(support.TESTFN, os.O_RDONLY) + def opener(path, flags): + return fd + with self.open("non-existent", "r", opener=opener) as f: + self.assertEqual(f.read(), "egg\n") + class CIOTest(IOTest): def test_IOBase_finalize(self): |