()
| 455 | |
| 456 | |
| 457 | def test_iso8601_datetime() -> None: |
| 458 | class Model(BaseModel): |
| 459 | created_at: datetime |
| 460 | |
| 461 | expected = datetime(2019, 12, 27, 18, 11, 19, 117000, tzinfo=timezone.utc) |
| 462 | |
| 463 | if PYDANTIC_V1: |
| 464 | expected_json = '{"created_at": "2019-12-27T18:11:19.117000+00:00"}' |
| 465 | else: |
| 466 | expected_json = '{"created_at":"2019-12-27T18:11:19.117000Z"}' |
| 467 | |
| 468 | model = Model.construct(created_at="2019-12-27T18:11:19.117Z") |
| 469 | assert model.created_at == expected |
| 470 | assert model_json(model) == expected_json |
| 471 | |
| 472 | model = parse_obj(Model, dict(created_at="2019-12-27T18:11:19.117Z")) |
| 473 | assert model.created_at == expected |
| 474 | assert model_json(model) == expected_json |
| 475 | |
| 476 | |
| 477 | def test_does_not_coerce_int() -> None: |
nothing calls this directly
no test coverage detected