summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorBrian Curtin <brian@python.org>2011-11-06 19:41:17 (GMT)
committerBrian Curtin <brian@python.org>2011-11-06 19:41:17 (GMT)
commit52fbea1d871c99bad3d6f113cebd01ac9c68d5b9 (patch)
tree1532ea1226432b76942a42344fec4b7c1b8b9944 /Lib/test/test_os.py
parent9589ab174577773c48492b4e2ad596d4b9c3b120 (diff)
downloadcpython-52fbea1d871c99bad3d6f113cebd01ac9c68d5b9.zip
cpython-52fbea1d871c99bad3d6f113cebd01ac9c68d5b9.tar.gz
cpython-52fbea1d871c99bad3d6f113cebd01ac9c68d5b9.tar.bz2
Fix #13327. Remove the need for an explicit None as the second argument to
os.utime in order to update to the current time. The second argument is now optional.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 878162f..b74d051 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -270,6 +270,21 @@ class StatAttributeTests(unittest.TestCase):
st2 = os.stat(support.TESTFN)
self.assertEqual(st2.st_mtime, int(st.st_mtime-delta))
+ def test_utime_noargs(self):
+ # (insert issue#) removed the requirement to pass None as the
+ # second argument. Check that the previous methods of passing
+ # a time tuple or None work in addition to no argument.
+ st = os.stat(support.TESTFN)
+ # Doesn't set anything new, but sets the time tuple way
+ os.utime(support.TESTFN, (st.st_atime, st.st_mtime))
+ # Set to the current time in the old explicit way.
+ os.utime(support.TESTFN, None)
+ st1 = os.stat(support.TESTFN)
+ # Set to the current time in the new way
+ os.utime(support.TESTFN)
+ st2 = os.stat(support.TESTFN)
+ self.assertAlmostEqual(st1.st_mtime, st2.st_mtime, delta=10)
+
# Restrict test to Win32, since there is no guarantee other
# systems support centiseconds
if sys.platform == 'win32':