litestar-org / litestar

Production-ready, Light, Flexible and Extensible ASGI API framework | Effortlessly Build Performant APIs
https://litestar.dev/
MIT License
5.12k stars 350 forks source link

Tests: AssertionError: assert datetime.date(2023, 8, 30) == datetime.date(2023, 8, 31) #2293

Open benjamin-kirkbride opened 10 months ago

benjamin-kirkbride commented 10 months ago

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


Funding

Fund with Polar

Alc-Alc commented 10 months ago

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)),
]
benjamin-kirkbride commented 10 months ago

@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

benjamin-kirkbride commented 10 months ago

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.

benjamin-kirkbride commented 10 months ago

Exact same thing again today. Curious if anyone else has this issue?

Goldziher commented 10 months ago

Exact same thing again today. Curious if anyone else has this issue?

No. Are you on win?

benjamin-kirkbride commented 10 months ago

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: @.***>

guacs commented 9 months ago

@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.

ccrvlh commented 9 months ago

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.

peterschutt commented 9 months ago

@ccrvlh have you explicitly installed pydantic V1 to replicate the issue? I can't replicate.

ccrvlh commented 9 months ago

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.

peterschutt commented 9 months ago

And are the failing tests the pydantic V1 tests, such as in OP?

ccrvlh commented 9 months ago

Yeah exactly the same tests as the original post fails.