MCPcopy Index your code
hub / github.com/python/cpython / test_tzinfo_utcfromtimestamp

Method test_tzinfo_utcfromtimestamp

Lib/test/datetimetester.py:5400–5413  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5398 self.assertRaises(TypeError, meth, tzinfo=off42)
5399
5400 def test_tzinfo_utcfromtimestamp(self):
5401 import time
5402 meth = self.theclass.utcfromtimestamp
5403 ts = time.time()
5404 # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
5405 with self.assertWarns(DeprecationWarning):
5406 base = meth(ts)
5407 # Try with and without naming the keyword; for whatever reason,
5408 # utcfromtimestamp() doesn't accept a tzinfo argument.
5409 off42 = FixedOffset(42, "42")
5410 with warnings.catch_warnings(category=DeprecationWarning):
5411 warnings.simplefilter("ignore", category=DeprecationWarning)
5412 self.assertRaises(TypeError, meth, ts, off42)
5413 self.assertRaises(TypeError, meth, ts, tzinfo=off42)
5414
5415 def test_tzinfo_timetuple(self):
5416 # TestDateTime tested most of this. datetime adds a twist to the

Callers

nothing calls this directly

Calls 5

methFunction · 0.85
FixedOffsetClass · 0.85
assertWarnsMethod · 0.80
timeMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected