diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-11-23 13:52:39 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-11-23 13:52:39 (GMT) |
commit | 8b78493d4f9eca2d8a90abdab7e905e9556eba57 (patch) | |
tree | e1e931a60610ae19592dc78b91ab4cda93a8730d | |
parent | 7e45d25ecbf1b9e937f5d02793e816e2a1323f9e (diff) | |
download | cpython-8b78493d4f9eca2d8a90abdab7e905e9556eba57.zip cpython-8b78493d4f9eca2d8a90abdab7e905e9556eba57.tar.gz cpython-8b78493d4f9eca2d8a90abdab7e905e9556eba57.tar.bz2 |
Issue #19716: add a test that Path.touch() doesn't change a file's contents.
Patch by Kushal Das.
-rwxr-xr-x | 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 index 6663ffa..83c56d0 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' |