mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Closes #27661: Added tzinfo keyword argument to datetime.combine.
This commit is contained in:
parent
711120d8fd
commit
43746c3770
5 changed files with 50 additions and 24 deletions
|
@ -2117,11 +2117,22 @@ class TestDateTime(TestDate):
|
|||
self.assertRaises(TypeError, combine) # need an arg
|
||||
self.assertRaises(TypeError, combine, d) # need two args
|
||||
self.assertRaises(TypeError, combine, t, d) # args reversed
|
||||
self.assertRaises(TypeError, combine, d, t, 1) # too many args
|
||||
self.assertRaises(TypeError, combine, d, t, 1) # wrong tzinfo type
|
||||
self.assertRaises(TypeError, combine, d, t, 1, 2) # too many args
|
||||
self.assertRaises(TypeError, combine, "date", "time") # wrong types
|
||||
self.assertRaises(TypeError, combine, d, "time") # wrong type
|
||||
self.assertRaises(TypeError, combine, "date", t) # wrong type
|
||||
|
||||
# tzinfo= argument
|
||||
dt = combine(d, t, timezone.utc)
|
||||
self.assertIs(dt.tzinfo, timezone.utc)
|
||||
dt = combine(d, t, tzinfo=timezone.utc)
|
||||
self.assertIs(dt.tzinfo, timezone.utc)
|
||||
t = time()
|
||||
dt = combine(dt, t)
|
||||
self.assertEqual(dt.date(), d)
|
||||
self.assertEqual(dt.time(), t)
|
||||
|
||||
def test_replace(self):
|
||||
cls = self.theclass
|
||||
args = [1, 2, 3, 4, 5, 6, 7]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue