summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2012-02-08 13:31:50 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2012-02-08 13:31:50 (GMT)
commitccd5715a149388eec2f40e5efacac83d3fe357ca (patch)
tree69b6582c3ed63f6527e56ebdc996c99dccbba910 /Lib/test/test_os.py
parent6f91ce74a04e958b2e5b1d1904110739eea66841 (diff)
downloadcpython-ccd5715a149388eec2f40e5efacac83d3fe357ca.zip
cpython-ccd5715a149388eec2f40e5efacac83d3fe357ca.tar.gz
cpython-ccd5715a149388eec2f40e5efacac83d3fe357ca.tar.bz2
PEP 410
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 4d27c2b..379dc58e 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -2,6 +2,7 @@
# does add tests for a few functions which have been determined to be more
# portable than they had been thought to be.
+import decimal
import os
import errno
import unittest
@@ -238,6 +239,36 @@ class StatAttributeTests(unittest.TestCase):
warnings.simplefilter("ignore", DeprecationWarning)
self.check_stat_attributes(fname)
+ def test_stat_timestamp(self):
+ # test deprecation
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", DeprecationWarning)
+ self.assertRaises(DeprecationWarning, os.stat_float_times, False)
+
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ old_value = os.stat_float_times()
+ try:
+ # test invalid timestamp types
+ self.assertRaises(ValueError, os.stat, self.fname,
+ timestamp="abc")
+ self.assertRaises(ValueError, os.stat, self.fname,
+ timestamp=decimal.Context)
+
+ for float_times in (False, True):
+ os.stat_float_times(float_times)
+ t = os.stat(self.fname).st_mtime
+ if float_times:
+ self.assertIsInstance(t, float)
+ else:
+ self.assertIsInstance(t, int)
+
+ for type in (int, float, decimal.Decimal):
+ t = os.stat(self.fname, timestamp=type).st_mtime
+ self.assertIsInstance(t, type)
+ finally:
+ os.stat_float_times(old_value)
+
def test_statvfs_attributes(self):
if not hasattr(os, "statvfs"):
return