plexpy/lib/win32com/test/testDates.py
dependabot[bot] faef9a94c4
Bump cherrypy from 18.8.0 to 18.9.0 (#2266)
* Bump cherrypy from 18.8.0 to 18.9.0

Bumps [cherrypy](https://github.com/cherrypy/cherrypy) from 18.8.0 to 18.9.0.
- [Changelog](https://github.com/cherrypy/cherrypy/blob/main/CHANGES.rst)
- [Commits](https://github.com/cherrypy/cherrypy/compare/v18.8.0...v18.9.0)

---
updated-dependencies:
- dependency-name: cherrypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update cherrypy==18.9.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>

[skip ci]
2024-03-24 15:25:44 -07:00

74 lines
1.8 KiB
Python

import unittest
from datetime import datetime
import pywintypes
import win32com.client
import win32com.server.util
import win32com.test.util
from win32timezone import TimeZoneInfo
# A COM object so we can pass dates to and from the COM boundary.
class Tester:
_public_methods_ = ["TestDate"]
def TestDate(self, d):
assert isinstance(d, datetime)
return d
def test_ob():
return win32com.client.Dispatch(win32com.server.util.wrap(Tester()))
class TestCase(win32com.test.util.TestCase):
def check(self, d, expected=None):
if not issubclass(pywintypes.TimeType, datetime):
self.skipTest("this is testing pywintypes and datetime")
got = test_ob().TestDate(d)
self.assertEqual(got, expected or d)
def testUTC(self):
self.check(
datetime(
year=2000,
month=12,
day=25,
microsecond=500000,
tzinfo=TimeZoneInfo.utc(),
)
)
def testLocal(self):
self.check(
datetime(
year=2000,
month=12,
day=25,
microsecond=500000,
tzinfo=TimeZoneInfo.local(),
)
)
def testMSTruncated(self):
# milliseconds are kept but microseconds are lost after rounding.
self.check(
datetime(
year=2000,
month=12,
day=25,
microsecond=500500,
tzinfo=TimeZoneInfo.utc(),
),
datetime(
year=2000,
month=12,
day=25,
microsecond=500000,
tzinfo=TimeZoneInfo.utc(),
),
)
if __name__ == "__main__":
unittest.main()