Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
abb8efdc
Commit
abb8efdc
authored
Mar 24, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update test to use local timestamps, so the tests pass in any timezone.
parent
4ad02f9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
tests/test_pkg_resources.py
tests/test_pkg_resources.py
+23
-4
No files found.
tests/test_pkg_resources.py
View file @
abb8efdc
...
...
@@ -2,6 +2,7 @@ import sys
import
tempfile
import
os
import
zipfile
import
datetime
import
pkg_resources
...
...
@@ -17,9 +18,25 @@ class EggRemover(unicode):
if
os
.
path
.
exists
(
self
):
os
.
remove
(
self
)
ZERO
=
datetime
.
timedelta
(
0
)
class
UTC
(
datetime
.
tzinfo
):
"""UTC"""
def
utcoffset
(
self
,
dt
):
return
ZERO
def
tzname
(
self
,
dt
):
return
"UTC"
def
dst
(
self
,
dt
):
return
ZERO
class
TestZipProvider
(
object
):
finalizers
=
[]
ref_time
=
datetime
.
datetime
(
2013
,
5
,
12
,
13
,
25
,
0
)
"A reference time for a file modification"
@
classmethod
def
setup_class
(
cls
):
"create a zip egg and add it to sys.path"
...
...
@@ -27,11 +44,11 @@ class TestZipProvider(object):
zip_egg
=
zipfile
.
ZipFile
(
egg
,
'w'
)
zip_info
=
zipfile
.
ZipInfo
()
zip_info
.
filename
=
'mod.py'
zip_info
.
date_time
=
2013
,
5
,
12
,
13
,
25
,
0
zip_info
.
date_time
=
cls
.
ref_time
.
timetuple
()
zip_egg
.
writestr
(
zip_info
,
'x = 3
\
n
'
)
zip_info
=
zipfile
.
ZipInfo
()
zip_info
.
filename
=
'data.dat'
zip_info
.
date_time
=
2013
,
5
,
12
,
13
,
25
,
0
zip_info
.
date_time
=
cls
.
ref_time
.
timetuple
()
zip_egg
.
writestr
(
zip_info
,
'hello, world!'
)
zip_egg
.
close
()
egg
.
close
()
...
...
@@ -55,11 +72,13 @@ class TestZipProvider(object):
manager
=
pkg_resources
.
ResourceManager
()
zp
=
pkg_resources
.
ZipProvider
(
mod
)
filename
=
zp
.
get_resource_filename
(
manager
,
'data.dat'
)
assert
os
.
stat
(
filename
).
st_mtime
==
1368379500
actual
=
datetime
.
datetime
.
fromtimestamp
(
os
.
stat
(
filename
).
st_mtime
)
assert
actual
==
self
.
ref_time
f
=
open
(
filename
,
'w'
)
f
.
write
(
'hello, world?'
)
f
.
close
()
os
.
utime
(
filename
,
(
1368379500
,
1368379500
))
ts
=
self
.
ref_time
.
timestamp
()
os
.
utime
(
filename
,
(
ts
,
ts
))
filename
=
zp
.
get_resource_filename
(
manager
,
'data.dat'
)
f
=
open
(
filename
)
assert
f
.
read
()
==
'hello, world!'
...
...
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