kennethreitz / maya

Datetimes for Humans™
MIT License
3.41k stars 199 forks source link

Test failure with Python 3.12 #202

Open fabaff opened 3 months ago

fabaff commented 3 months ago

Describe the bug Tests starting to fail with python 3.12. They are passing with Python 3.11.

============================= test session starts ==============================
platform linux -- Python 3.12.2, pytest-7.4.4, pluggy-1.4.0
rootdir: /build/source
plugins: mock-3.12.0, time_machine-2.13.0
collected 277 items                                                            

tests/test_maya.py ..FF................................................. [ 19%]
........................................................................ [ 45%]
................................................................         [ 68%]
tests/test_maya_interval.py ............................................ [ 84%]
............................................                             [100%]

=================================== FAILURES ===================================
____ test_parse_iso8601[20161001T1430.4+05:30-2016-10-01T09:00:00.400000Z] _____

text = '20161001T1430.4+05:30'
[...]
        # We couldn't parse the string
        # so we fallback on the dateutil parser
        # If not strict
        if options.get("strict", True):
            raise ParserError(f"Unable to parse string [{text}]")

        try:
            dt = parser.parse(
                text, dayfirst=options["day_first"], yearfirst=options["year_first"]
            )
        except ValueError:
>           raise ParserError(f"Invalid date string: {text}")
E           pendulum.parsing.exceptions.ParserError: Invalid date string: 2016T14

/nix/store/93iilxyrqxs4l1da1c595w8l8ga9g5s8-python3.12-pendulum-3.0.0/lib/python3.12/site-packages/pendulum/parsing/__init__.py:132: ParserError
=============================== warnings summary ===============================
tests/test_maya.py: 669 warnings
tests/test_maya_interval.py: 530 warnings
  /build/source/maya/core.py:250: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    dt = Datetime.utcfromtimestamp(self._epoch)

tests/test_maya.py::test_issue_104
  /build/source/tests/test_maya.py:81: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    t = Datetime.utcfromtimestamp(e)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_maya.py::test_parse_iso8601[20161001T1430.4+05:30-2016-10-01T09:00:00.400000Z] - pendulum.parsing.exceptions.ParserError: Invalid date string: 20161001T1430...
FAILED tests/test_maya.py::test_parse_iso8601[2016T14-2016-01-01T14:00:00Z] - pendulum.parsing.exceptions.ParserError: Invalid date string: 2016T14
================= 2 failed, 275 passed, 1200 warnings in 1.81s =================

Environment and Version

To Reproduce Run tests

Expected behavior Tests to pass with Python 3.12

Screenshots If applicable, add screenshots to help explain your problem.

Relevant log files If applicable, information from log files supporting your claim.

Additional context Add any other context about the problem here.

timofurrer commented 3 months ago

I'm not maintaining this any more.

Looking for maintainers here: https://github.com/timofurrer/maya/issues/197 - no luck so far.

If anyone wants to contribute this, don't hesitate :)

FluffyDietEngine commented 3 months ago

@fabaff I was able to reproduce the same test results with python3.11 as well. Digging down deep, the issue is arising from pendulum version. From 3.0.0a1, these tests are failing. If the dependency is downgraded to 2.1.2, the tests are not failing.

My suggestion would be understanding whether these two date formats 20161001T1430.4+05:30-2016-10-01T09:00:00.400000Z and 2016T14-2016-01-01T14:00:00Z are still valid according to iso8601 and remove from tests if they are not.

@timofurrer I am interested in maintaining the repo, even though I do not have much of experience in open source, but I do have experience in handling projects in work for last 8 years.