Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
be557ded
Commit
be557ded
authored
Feb 08, 2012
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #13964: Write tests for new os.*utime*() functions
parent
f4c54ff5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
Lib/test/test_os.py
Lib/test/test_os.py
+37
-0
No files found.
Lib/test/test_os.py
View file @
be557ded
...
...
@@ -300,6 +300,43 @@ class StatAttributeTests(unittest.TestCase):
st2
=
os
.
stat
(
support
.
TESTFN
)
self
.
assertAlmostEqual
(
st1
.
st_mtime
,
st2
.
st_mtime
,
delta
=
10
)
def
test_utime_subsecond
(
self
):
asec
,
amsec
=
1
,
901
atime
=
asec
+
amsec
*
1e-3
msec
,
mmsec
=
5
,
901
mtime
=
msec
+
mmsec
*
1e-3
filename
=
self
.
fname
dirname
=
os
.
path
.
dirname
(
filename
)
for
func
in
(
'utime'
,
'futimes'
,
'futimens'
,
'lutimes'
,
'utimensat'
):
if
not
hasattr
(
os
,
func
):
continue
os
.
utime
(
filename
,
(
0
,
0
))
if
func
==
'utime'
:
os
.
utime
(
filename
,
(
atime
,
mtime
))
elif
func
==
'futimes'
:
with
open
(
filename
,
"wb"
)
as
f
:
os
.
futimes
(
f
.
fileno
(),
(
atime
,
mtime
))
os
.
utime
(
filename
,
(
atime
,
mtime
))
elif
func
==
'futimens'
:
with
open
(
filename
,
"wb"
)
as
f
:
os
.
futimens
(
f
.
fileno
(),
(
asec
,
amsec
*
1000000
),
(
msec
,
mmsec
*
1000000
))
elif
func
==
'lutimes'
:
os
.
lutimes
(
filename
,
(
atime
,
mtime
))
else
:
dirfd
=
os
.
open
(
dirname
,
os
.
O_RDONLY
)
try
:
os
.
utimensat
(
dirfd
,
os
.
path
.
basename
(
filename
),
(
asec
,
amsec
*
1000000
),
(
msec
,
mmsec
*
1000000
))
finally
:
os
.
close
(
dirfd
)
st
=
os
.
stat
(
filename
)
self
.
assertAlmostEqual
(
st
.
st_atime
,
atime
,
places
=
3
)
self
.
assertAlmostEqual
(
st
.
st_mtime
,
mtime
,
places
=
3
)
# Restrict test to Win32, since there is no guarantee other
# systems support centiseconds
if
sys
.
platform
==
'win32'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment