]> granicus.if.org Git - python/commitdiff
Issue #19716: add a test that Path.touch() doesn't change a file's contents.
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 23 Nov 2013 13:52:39 +0000 (14:52 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 23 Nov 2013 13:52:39 +0000 (14:52 +0100)
Patch by Kushal Das.

Lib/test/test_pathlib.py

index 6663ffa2833e02e420dd1c5eec458df897154b60..83c56d0d9bcb211d15dfb6a0dd545e7e3be068af 100755 (executable)
@@ -1403,6 +1403,13 @@ class _BasePathTest(object):
         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'