Skip to content

Test on Python 3.12#3266

Merged
hmpf merged 7 commits intoUninett:masterfrom
hmpf:test/python3.12
Sep 16, 2025
Merged

Test on Python 3.12#3266
hmpf merged 7 commits intoUninett:masterfrom
hmpf:test/python3.12

Conversation

@hmpf
Copy link
Copy Markdown
Contributor

@hmpf hmpf commented Jan 28, 2025

Depends on #2850

If using devcontainers, set MAIN_PYTHON_VERSION in devcontainer/docker-compose.yml to 3.12.

This pull request

  • adds/changes/removes a dependency

Removed test requirements:

  • astroid (used by pylint)
  • lxml (used by napalm)

Changed:

  • chromedriver, for tests

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • [ ] Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • This pull request is based on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • [ ] If this results in changes in the UI: Added screenshots of the before and after
  • [ ] If this adds a new Python source code file: Added the boilerplate header to that file

@hmpf hmpf added the django label Jan 28, 2025
@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.05%. Comparing base (a059c99) to head (354396d).
⚠️ Report is 346 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3266      +/-   ##
==========================================
+ Coverage   61.61%   62.05%   +0.44%     
==========================================
  Files         611      611              
  Lines       44813    44854      +41     
  Branches       43       43              
==========================================
+ Hits        27610    27835     +225     
+ Misses      17193    17009     -184     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lunkwill42
Copy link
Copy Markdown
Member

I guess this needs a rebase, as #2850 was modified and merged..

@hmpf hmpf force-pushed the test/python3.12 branch from 75cfbb3 to e99dae0 Compare May 9, 2025 06:51
@hmpf
Copy link
Copy Markdown
Contributor Author

hmpf commented May 9, 2025

Python 3.12 needs an lxml that is newer than or equal to 5.0.

@hmpf
Copy link
Copy Markdown
Contributor Author

hmpf commented May 9, 2025

Warnings:

python/nav/django/settings.py:73
UserWarning: Could not get connection parameters from db.conf: [Errno 2] No such file or directory: 'db.conf'
    warnings.warn(f"Could not get connection parameters from db.conf: {e}")

VENV/lib/python3.12/site-packages/django/conf/__init__.py:241
RemovedInDjango50Warning: The default value of USE_TZ will change from False to True in Django 5.0. Set USE_TZ to False in your project settings if you want to keep the current default behavior.
    warnings.warn(

python/nav/smidumps/DNOS-SWITCHING-MIB.py:10057
SyntaxWarning: invalid escape sequence '\c'
    """Transfer upload tftpfilename configures the file name for the file being

VENV/lib/python3.12/site-packages/napalm/__init__.py:1
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

VENV/lib/python3.12/site-packages/pkg_resources/__init__.py:3147
DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('jnpr')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

VENV/lib/python3.12/site-packages/napalm/ios/ios.py:22
DeprecationWarning: 'telnetlib' is deprecated and slated for removal in Python 3.13
    import telnetlib

@hmpf
Copy link
Copy Markdown
Contributor Author

hmpf commented May 9, 2025

Warnings during testing:

tests/unittests/web/webfront_test.py::test_tools_should_be_split_in_3_columns PASSED                                                                                                                  [100%]<unknown>:402: SyntaxWarning: invalid escape sequence '\['
<unknown>:404: SyntaxWarning: invalid escape sequence '\s'
VENV/python/nav/bin/radiusparser.py:402: SyntaxWarning: invalid escape sequence '\['
  '^(?P<time>.*) : (?P<type>Auth): (?P<message>(?P<status>.*?): \[(?P<user>.*?)\] \(from client (?P<client>[^ ]+) port (?P<port>[^ ]+)( cli (?P<cli>[^ ]+)|)\))\s*$'
VENV/python/nav/bin/radiusparser.py:404: SyntaxWarning: invalid escape sequence '\s'
  other_pattern = re.compile('^(?P<time>.*) : (?P<type>[^:]+): (?P<message>.*?)\s*$')

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented May 9, 2025

@lunkwill42 lunkwill42 added the nonews No news fragment is necessary for this PR (e.g. refactoring, cleanups, workflow/development changes) label Aug 18, 2025
@lunkwill42
Copy link
Copy Markdown
Member

Rebased on latest master

@lunkwill42
Copy link
Copy Markdown
Member

We should really add 3.13 to this also :)

@hmpf hmpf changed the title Test on Python 3.12 Test on Python 3.12 and 3.13 Aug 25, 2025
@hmpf hmpf changed the title Test on Python 3.12 and 3.13 Test on Python 3.12 Aug 25, 2025
@hmpf hmpf force-pushed the test/python3.12 branch from e7bce7a to c88094b Compare August 25, 2025 11:50
@hmpf
Copy link
Copy Markdown
Contributor Author

hmpf commented Aug 26, 2025

Newest problem:

ERROR tests/functional/arnold_test.py::test_title_should_contain_detentions - selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 133

@hmpf
Copy link
Copy Markdown
Contributor Author

hmpf commented Aug 26, 2025

We should really add 3.13 to this also :)

Nah, we need to be up and running on Django 5.2 first. 4.2 only supports up to and including 3.12.

@hmpf hmpf force-pushed the test/python3.12 branch from c88094b to 8eaadc4 Compare August 27, 2025 06:58
@hmpf hmpf requested a review from lunkwill42 August 27, 2025 07:00
@hmpf hmpf force-pushed the test/python3.12 branch from ddd47f2 to 7c25f68 Compare August 27, 2025 08:27
@lunkwill42
Copy link
Copy Markdown
Member

lunkwill42 commented Aug 27, 2025

<unknown>:404: SyntaxWarning: invalid escape sequence '\s'

This one is a bit hard to locate 😏

@lunkwill42 lunkwill42 mentioned this pull request Aug 27, 2025
9 tasks
@hmpf hmpf force-pushed the test/python3.12 branch from 7c25f68 to 764c910 Compare August 27, 2025 10:58
@hmpf
Copy link
Copy Markdown
Contributor Author

hmpf commented Aug 28, 2025

Here's a solution to the USE_L10N-flag disappearing:

https://docs.djangoproject.com/en/5.2/topics/i18n/formatting/#creating-custom-format-files

@hmpf hmpf force-pushed the test/python3.12 branch 2 times, most recently from f249aa2 to 4af2196 Compare September 5, 2025 11:17
hmpf added 4 commits September 9, 2025 13:00
Astroid is a requirement of pylint which we no longer use.
Lxml is a dependency of napalm and napalm should control its version.
This was the unset default of Django's until but not including Django
5.0. Nav depends on it being "False" and changing it to "True" would be
a major undertaking.
@hmpf hmpf requested a review from a team September 9, 2025 11:12
Copy link
Copy Markdown
Contributor

@johannaengland johannaengland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nitpick about the argument to naventity

It's this high because while 15 (the old one + the new 5 sec timeout to
naventity, round up) is high enough when testing locally, GitHub CI
needed 20.
@hmpf hmpf merged commit 437d239 into Uninett:master Sep 16, 2025
10 of 11 checks passed
@hmpf hmpf deleted the test/python3.12 branch September 16, 2025 08:23
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

django nonews No news fragment is necessary for this PR (e.g. refactoring, cleanups, workflow/development changes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants