Update of /cvsroot/pywin32/pywin32/win32/test
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4651/win32/test
Modified Files:
test_win32api.py test_win32file.py
Log Message:
Merge optional support for using datetime objects from py3k-integration
branch. Currently must be enabled at build time and only currently
enabled for py3k (although it does work with all versions >= 2.4)
Index: test_win32file.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** test_win32file.py 25 Jan 2009 23:50:53 -0000 1.28
--- test_win32file.py 26 Jan 2009 00:47:31 -0000 1.29
***************
*** 3,6 ****
--- 3,7 ----
import win32api, win32file, win32pipe, pywintypes, winerror, win32event
import win32con, ntsecuritycon
+ import win32timezone
import sys
import os
***************
*** 122,125 ****
--- 123,153 ----
os.unlink(filename)
+ def testFileTimesTimezones(self):
+ if not issubclass(pywintypes.TimeType, datetime.datetime):
+ # maybe should report 'skipped', but that's not quite right as
+ # there is nothing you can do to avoid it being skipped!
+ return
+ filename = tempfile.mktemp("-testFileTimes")
+ now_utc = win32timezone.utcnow()
+ now_local = now_utc.astimezone(win32timezone.TimeZoneInfo.local())
+ h = win32file.CreateFile(filename,
+ win32file.GENERIC_READ|win32file.GENERIC_WRITE,
+ 0, None, win32file.CREATE_ALWAYS, 0, 0)
+ try:
+ win32file.SetFileTime(h, now_utc, now_utc, now_utc)
+ ct, at, wt = win32file.GetFileTime(h)
+ self.failUnlessEqual(now_local, ct)
+ self.failUnlessEqual(now_local, at)
+ self.failUnlessEqual(now_local, wt)
+ # and the reverse - set local, check against utc
+ win32file.SetFileTime(h, now_local, now_local, now_local)
+ ct, at, wt = win32file.GetFileTime(h)
+ self.failUnlessEqual(now_utc, ct)
+ self.failUnlessEqual(now_utc, at)
+ self.failUnlessEqual(now_utc, wt)
+ finally:
+ h.close()
+ os.unlink(filename)
+
def testFileTimes(self):
if issubclass(pywintypes.TimeType, datetime.datetime):
Index: test_win32api.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32api.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** test_win32api.py 7 Jan 2009 06:03:29 -0000 1.16
--- test_win32api.py 26 Jan 2009 00:47:31 -0000 1.17
***************
*** 7,10 ****
--- 7,11 ----
import sys, os
import tempfile
+ import datetime
class CurrentUserTestCase(unittest.TestCase):
***************
*** 25,29 ****
# for the sake of code exercise but don't output
tz_str.encode()
! tz_time.Format()
def TestDateFormat(self):
DATE_LONGDATE = 2
--- 26,31 ----
# for the sake of code exercise but don't output
tz_str.encode()
! if not isinstance(tz_time, datetime.datetime):
! tz_time.Format()
def TestDateFormat(self):
DATE_LONGDATE = 2
|