(self)
| 1520 | self.assertNotEqual(dt1, type(dec1["x"])) |
| 1521 | |
| 1522 | def test_clamping(self): |
| 1523 | # Test clamping from below and above. |
| 1524 | opts = CodecOptions( |
| 1525 | datetime_conversion=DatetimeConversion.DATETIME_CLAMP, |
| 1526 | tz_aware=True, |
| 1527 | tzinfo=datetime.timezone.utc, |
| 1528 | ) |
| 1529 | below = encode({"x": DatetimeMS(_datetime_to_millis(datetime.datetime.min) - 1)}) |
| 1530 | dec_below = decode(below, opts) |
| 1531 | self.assertEqual( |
| 1532 | dec_below["x"], datetime.datetime.min.replace(tzinfo=datetime.timezone.utc) |
| 1533 | ) |
| 1534 | |
| 1535 | above = encode({"x": DatetimeMS(_datetime_to_millis(datetime.datetime.max) + 1)}) |
| 1536 | dec_above = decode(above, opts) |
| 1537 | self.assertEqual( |
| 1538 | dec_above["x"], |
| 1539 | datetime.datetime.max.replace(tzinfo=datetime.timezone.utc, microsecond=999000), |
| 1540 | ) |
| 1541 | |
| 1542 | def test_tz_clamping_local(self): |
| 1543 | # Naive clamping to local tz. |
nothing calls this directly
no test coverage detected