[Python-checkins] cpython: Issue #19716: add a test that Path.touch() doesn't change a file's contents.

antoine.pitrou python-checkins at python.org
Sat Nov 23 14:53:12 CET 2013


http://hg.python.org/cpython/rev/11a200202d7a
changeset:   87416:11a200202d7a
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sat Nov 23 14:52:39 2013 +0100
summary:
  Issue #19716: add a test that Path.touch() doesn't change a file's contents.
Patch by Kushal Das.

files:
  Lib/test/test_pathlib.py |  7 +++++++
  1 files changed, 7 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -1403,6 +1403,13 @@
         self.assertTrue(p.exists())
         self.assertRaises(OSError, p.touch, exist_ok=False)
 
+    def test_touch_nochange(self):
+        P = self.cls(BASE)
+        p = P / 'fileA'
+        p.touch()
+        with p.open('rb') as f:
+            self.assertEqual(f.read().strip(), b"this is file A")
+
     def test_mkdir(self):
         P = self.cls(BASE)
         p = P / 'newdirA'

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list