aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-03-24 11:48:15 +0000
committerJason R. Coombs <jaraco@jaraco.com>2014-03-24 11:48:15 +0000
commit8f5e0004edcd54aafe7f6fc30527f20aa8e05838 (patch)
treec48af857c2efcdd3887297b5abe764be1ab42841
parentabb8efdc4aeaa0d31c82ecf9f96d115b34e70b4e (diff)
downloadexternal_python_setuptools-8f5e0004edcd54aafe7f6fc30527f20aa8e05838.tar.gz
external_python_setuptools-8f5e0004edcd54aafe7f6fc30527f20aa8e05838.tar.bz2
external_python_setuptools-8f5e0004edcd54aafe7f6fc30527f20aa8e05838.zip
Use mktime for Python 3.2 compatibility
-rw-r--r--tests/test_pkg_resources.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/test_pkg_resources.py b/tests/test_pkg_resources.py
index 8ce77255..ed414096 100644
--- a/tests/test_pkg_resources.py
+++ b/tests/test_pkg_resources.py
@@ -3,6 +3,7 @@ import tempfile
import os
import zipfile
import datetime
+import time
import pkg_resources
@@ -11,6 +12,16 @@ try:
except NameError:
unicode = str
+def timestamp(dt):
+ """
+ Return a timestamp for a local, naive datetime instance.
+ """
+ try:
+ return dt.timestamp()
+ except AttributeError:
+ # Python 3.2 and earlier
+ return time.mktime(dt.timetuple())
+
class EggRemover(unicode):
def __call__(self):
if self in sys.path:
@@ -77,7 +88,7 @@ class TestZipProvider(object):
f = open(filename, 'w')
f.write('hello, world?')
f.close()
- ts = self.ref_time.timestamp()
+ ts = timestamp(self.ref_time)
os.utime(filename, (ts, ts))
filename = zp.get_resource_filename(manager, 'data.dat')
f = open(filename)