From: Antoine Pitrou Date: Sat, 23 Nov 2013 13:52:39 +0000 (+0100) Subject: Issue #19716: add a test that Path.touch() doesn't change a file's contents. X-Git-Tag: v3.4.0b1~69^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8b78493d4f9eca2d8a90abdab7e905e9556eba57;p=thirdparty%2FPython%2Fcpython.git Issue #19716: add a test that Path.touch() doesn't change a file's contents. Patch by Kushal Das. --- diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 6663ffa2833e..83c56d0d9bcb 100755 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -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'