litestar
litestar copied to clipboard
Tests: AssertionError: assert datetime.date(2023, 8, 30) == datetime.date(2023, 8, 31)
Description
I just installed Litestar from the repo for dev purposes following the instructions found here.
I ran the tests with make test
and got the following:
FAILED tests/unit/test_openapi/test_constrained_fields.py::test_create_date_constrained_field_schema_pydantic_v1[ConstrainedDateValue2] - AssertionError: assert datetime.date(2023, 8, 30) == datetime.date(2023, 8, 31)
FAILED tests/unit/test_openapi/test_constrained_fields.py::test_create_date_constrained_field_schema_pydantic_v1[ConstrainedDateValue3] - AssertionError: assert datetime.date(2023, 8, 30) == datetime.date(2023, 8, 31)
FAILED tests/unit/test_openapi/test_constrained_fields.py::test_create_date_constrained_field_schema_pydantic_v1[ConstrainedDateValue0] - AssertionError: assert datetime.date(2023, 8, 30) == datetime.date(2023, 8, 31)
FAILED tests/unit/test_openapi/test_constrained_fields.py::test_create_date_constrained_field_schema_pydantic_v1[ConstrainedDateValue1] - AssertionError: assert datetime.date(2023, 8, 30) == datetime.date(2023, 8, 31)
FAILED tests/unit/test_openapi/test_schema.py::test_annotated_types - assert datetime.date(1979, 12, 31) == datetime.date(1980, 1, 1)
Litestar Version
2.0.0
Platform
- [X] Linux
- [ ] Mac
- [ ] Windows
- [ ] Other (Please specify in the description above)
Funding
- If you would like to see an issue prioritized, make a pledge towards it!
- We receive the pledge once the issue is completed & verified
Can you check if in the file tests/unit/test_openapi/utils.py
if you make the following change the tests pass?
from datetime import datetime, timezone
today = datetime.now(timezone.utc).date().today()
constrained_dates = [
condate(gt=today - timedelta(days=10), lt=today + timedelta(days=100)),
condate(ge=today - timedelta(days=10), le=today + timedelta(days=100)),
condate(gt=today - timedelta(days=10), lt=today + timedelta(days=100)),
condate(ge=today - timedelta(days=10), le=today + timedelta(days=100)),
]
@Alc-Alc
FAILED
tests/unit/test_openapi/test_constrained_fields.py::test_create_date_constrained_field_schema_pydantic_v1[ConstrainedDateValue2] - AssertionError: assert datetime.date(2023, 8, 30) == datetime.date(2023, 8, 31)
FAILED tests/unit/test_openapi/test_constrained_fields.py::test_create_date_constrained_field_schema_pydantic_v1[ConstrainedDateValue1] - AssertionError: assert datetime.date(2023, 8, 30) == datetime.date(2023, 8, 31)
FAILED tests/unit/test_openapi/test_constrained_fields.py::test_create_date_constrained_field_schema_pydantic_v1[ConstrainedDateValue0] - AssertionError: assert datetime.date(2023, 8, 30) == datetime.date(2023, 8, 31)
FAILED tests/unit/test_openapi/test_constrained_fields.py::test_create_date_constrained_field_schema_pydantic_v1[ConstrainedDateValue3] - AssertionError: assert datetime.date(2023, 8, 30) == datetime.date(2023, 8, 31)
FAILED tests/unit/test_openapi/test_schema.py::test_annotated_types - assert datetime.date(1979, 12, 31) == datetime.date(1980, 1, 1)
Seemingly no change
The issue persists if I replace the time delta of 10 days to 11, or 2 days. So it doesn't seem to be an issue due to it being the 10th.
Exact same thing again today. Curious if anyone else has this issue?
Exact same thing again today. Curious if anyone else has this issue?
No. Are you on win?
Linux. Debian specifically
On Tue, Sep 12, 2023, 12:41 AM Goldziher @.***> wrote:
Exact same thing again today. Curious if anyone else has this issue?
No. Are you on win?
— Reply to this email directly, view it on GitHub https://github.com/litestar-org/litestar/issues/2293#issuecomment-1714952643, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZXWBXWPO6Q67ICRBNLU73XZ7RWPANCNFSM6AAAAAA4SH3RJY . You are receiving this because you authored the thread.Message ID: @.***>
@benjamin-kirkbride Do you know why pydantic v1
was installed instead of pydantic v2
? By default, pydantic v2
should be installed when doing poetry install --extras full
.
Same behavior on macOS. My initial impression was that this was related to timezones, so I tried replacing a couple of .now()
to utcnow()
, and some other today()
logic, but found the same errors, haven't tried playing around with different dependencies though.
@ccrvlh have you explicitly installed pydantic V1 to replicate the issue? I can't replicate.
No, I just followed the contributing guide, no manual intervention on dependencies (checked today and Pydantic v2 is installed). I'll try rebuilding the environment tomorrow. I got the same errors both on an M1 and Intel macOS.
And are the failing tests the pydantic V1 tests, such as in OP?
Yeah exactly the same tests as the original post fails.