diff options
author | Zhiming Wang <zmwangx@gmail.com> | 2017-09-04 17:37:24 (GMT) |
---|---|---|
committer | ericvsmith <ericvsmith@users.noreply.github.com> | 2017-09-04 17:37:24 (GMT) |
commit | 06de1aeff94e524bed21d188065c4cd1590fb046 (patch) | |
tree | 67a27d5e57c48158f66d36a99907ae07d8578f34 /Lib/test | |
parent | a2344851abd3b146ff09d3fc13adb262a7c5450b (diff) | |
download | cpython-06de1aeff94e524bed21d188065c4cd1590fb046.zip cpython-06de1aeff94e524bed21d188065c4cd1590fb046.tar.gz cpython-06de1aeff94e524bed21d188065c4cd1590fb046.tar.bz2 |
bpo-31281: Fix pathlib.Path incompatibility in fileinput (gh-3208)
Fix fileinput with inplace=True to accept pathlib.Path objects.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_fileinput.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py index 5df810c..d7efc68 100644 --- a/Lib/test/test_fileinput.py +++ b/Lib/test/test_fileinput.py @@ -544,6 +544,19 @@ class FileInputTests(unittest.TestCase): finally: remove_tempfiles(t1) + def test_pathlib_file_inplace(self): + t1 = None + try: + t1 = Path(writeTmp(1, ['Pathlib file.'])) + with FileInput(t1, inplace=True) as fi: + line = fi.readline() + self.assertEqual(line, 'Pathlib file.') + print('Modified %s' % line) + with open(t1) as f: + self.assertEqual(f.read(), 'Modified Pathlib file.\n') + finally: + remove_tempfiles(t1) + class MockFileInput: """A class that mocks out fileinput.FileInput for use during unit tests""" |