diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-30 21:08:52 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-30 21:08:52 (GMT) |
commit | f3b2d88b676d5624aed157a70bfa5b606f8249ed (patch) | |
tree | e7f58514c9cffb403e33b41b65aba63399d255c4 /Lib | |
parent | 8a8945085f6f91688d2c8792acf1154322479816 (diff) | |
download | cpython-f3b2d88b676d5624aed157a70bfa5b606f8249ed.zip cpython-f3b2d88b676d5624aed157a70bfa5b606f8249ed.tar.gz cpython-f3b2d88b676d5624aed157a70bfa5b606f8249ed.tar.bz2 |
Issue #8828: Add new function os.replace(), for cross-platform renaming with overwriting.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_os.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index e78db48..293005b 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -129,6 +129,18 @@ class FileTests(unittest.TestCase): self.fdopen_helper('r') self.fdopen_helper('r', 100) + def test_replace(self): + TESTFN2 = support.TESTFN + ".2" + with open(support.TESTFN, 'w') as f: + f.write("1") + with open(TESTFN2, 'w') as f: + f.write("2") + self.addCleanup(os.unlink, TESTFN2) + os.replace(support.TESTFN, TESTFN2) + self.assertRaises(FileNotFoundError, os.stat, support.TESTFN) + with open(TESTFN2, 'r') as f: + self.assertEqual(f.read(), "1") + # Test attributes on return values from os.*stat* family. class StatAttributeTests(unittest.TestCase): |