summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-30 21:08:52 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-30 21:08:52 (GMT)
commitf3b2d88b676d5624aed157a70bfa5b606f8249ed (patch)
treee7f58514c9cffb403e33b41b65aba63399d255c4 /Lib
parent8a8945085f6f91688d2c8792acf1154322479816 (diff)
downloadcpython-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.py12
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):