MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_utc_offset_out_of_bounds

Method test_utc_offset_out_of_bounds

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

Source from the content-addressed store, hash-verified

4225 self.assertIs(t.tzinfo, b)
4226
4227 def test_utc_offset_out_of_bounds(self):
4228 class Edgy(tzinfo):
4229 def __init__(self, offset):
4230 self.offset = timedelta(minutes=offset)
4231 def utcoffset(self, dt):
4232 return self.offset
4233
4234 cls = self.theclass
4235 for offset, legit in ((-1440, False),
4236 (-1439, True),
4237 (1439, True),
4238 (1440, False)):
4239 if cls is time:
4240 t = cls(1, 2, 3, tzinfo=Edgy(offset))
4241 elif cls is datetime:
4242 t = cls(6, 6, 6, 1, 2, 3, tzinfo=Edgy(offset))
4243 else:
4244 assert 0, "impossible"
4245 if legit:
4246 aofs = abs(offset)
4247 h, m = divmod(aofs, 60)
4248 tag = "%c%02d:%02d" % (offset < 0 and '-' or '+', h, m)
4249 if isinstance(t, datetime):
4250 t = t.timetz()
4251 self.assertEqual(str(t), "01:02:03" + tag)
4252 else:
4253 self.assertRaises(ValueError, str, t)
4254
4255 def test_tzinfo_classes(self):
4256 cls = self.theclass

Callers

nothing calls this directly

Calls 9

EdgyClass · 0.85
isinstanceFunction · 0.85
strFunction · 0.85
timetzMethod · 0.80
clsClass · 0.50
absFunction · 0.50
divmodFunction · 0.50
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected