Skip to content

test: fix Python 3.14 datetime deprecation#671

Merged
simonw merged 2 commits into
simonw:mainfrom
fry69:fry69/issue669
Nov 23, 2025
Merged

test: fix Python 3.14 datetime deprecation#671
simonw merged 2 commits into
simonw:mainfrom
fry69:fry69/issue669

Conversation

@fry69

@fry69 fry69 commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

fix #669

This tiny patch fixes the Python 3.14 datetime deprecation warning while maintaining expected output format (without timezone information).

It should be compatible with Python 3.10 and up, but I have not tested this explicitly.

Update: The 2nd commit adds a suppression for another Python 3.14 related warning.

Pytest now runs completely without warnings on Python 3.14:

$ pytest
=== test session starts ===
platform darwin -- Python 3.14.0, pytest-8.4.2, pluggy-1.6.0
[...]
=== 1001 passed, 16 skipped in 5.94s ===

Generated explanation below:


Added a pytest marker to the test_dateparse_errors function:

@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
def test_dateparse_errors(fresh_db, fn, errors):
    # ... test code ...

This decorator tells pytest to ignore PytestUnraisableExceptionWarning warnings for this specific test. This is the correct approach because:

  1. The warnings are informational, not errors - The exceptions ARE being properly handled (they result in OperationalError as expected)
  2. This is expected behavior - When SQLite user-defined functions raise exceptions, SQLite converts them to OperationalError, which the test correctly catches
  3. Python 3.14 is just more strict - The new warning system flags these as "unraisable" even though they're handled correctly
  4. Test-specific solution - Only the tests that intentionally trigger exceptions need this filter

📚 Documentation preview 📚: https://sqlite-utils--671.org.readthedocs.build/en/671/

@simonw simonw added the ci label Nov 23, 2025
@simonw

simonw commented Nov 23, 2025

Copy link
Copy Markdown
Owner

Thanks for this.

@simonw
simonw merged commit 42d23f5 into simonw:main Nov 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some DeprecationWarning in test suite with Python 3.14

2 participants