Skip to content

Commit

Permalink
Add support for Python 3.12
Browse files Browse the repository at this point in the history
* Add support for Python 3.12
* Also, update the GitHub Actions workflow matrix so that we test
  all supported pip versions with Python 3.8–3.11, but only pip 23
  on Python 3.12.
  • Loading branch information
Maari Tamm committed Apr 15, 2024
1 parent 9bd296c commit 22218f3
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 20 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
pip-version:
- 22.0.4
- 23.0.1
- 23.2.1
include:
- python-version: '3.12'
pip-version: '23.2.1'

steps:
- name: Check out code
Expand All @@ -27,7 +31,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install "tox<4" tox-gh-actions tox-pip-version
pip install "tox<4" tox-gh-actions tox-pip-version setuptools
- env:
TOX_PIP_VERSION: ${{ matrix.pip-version }}
name: Test with tox (pip ${{ matrix.pip-version }})
Expand Down
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Unreleased
-------------------------
* [Enhancement] Add support for Python 3.12.

Version 7.9.1 (2024-02-14)
-------------------------
* [Bug fix] Don't allow accessing a fullscreen lab directly from a URL,
Expand Down
4 changes: 2 additions & 2 deletions hastexo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pkg_resources
from importlib import metadata
# __version__ attribute as suggested by (deferred) PEP 396:
# https://www.python.org/dev/peps/pep-0396/
#
# Single-source package definition as suggested (among several
# options) by:
# https://packaging.python.org/guides/single-sourcing-package-version/
__version__ = pkg_resources.get_distribution('hastexo-xblock').version
__version__ = metadata.version('hastexo-xblock')
3 changes: 1 addition & 2 deletions hastexo/hastexo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import time
import logging
import os
import pkg_resources
import re
import string
import textwrap
Expand Down Expand Up @@ -621,7 +620,7 @@ def get_js_urls(self):
lang_code = translation.get_language()
if lang_code and lang_code in SUPPORTED_LANGUAGES:
text_js_url = f'public/js/translations/{lang_code}/text.js'
if pkg_resources.resource_exists(loader.module_name, text_js_url):
if os.path.exists(os.path.join('hastexo', text_js_url)):
js_urls["text_js_url"] = self.runtime.local_resource_url(
self, text_js_url)
else:
Expand Down
2 changes: 1 addition & 1 deletion requirements/setup.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-r base.txt
setuptools-scm<6
setuptools-scm
bumpversion
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ def package_data(pkg, roots):
"migrations",
"translations",
"locale"]),
setup_requires=['setuptools-scm<6'],
setup_requires=['setuptools-scm'],
)
4 changes: 2 additions & 2 deletions tests/unit/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_clear_stacklog(self):
stack.status = 'SUSPEND_COMPLETE'
stack.save(update_fields=["status"])
logs = StackLog.objects.filter(stack_id=self.stack.id)
self.assertEquals(logs.count(), 4)
self.assertEqual(logs.count(), 4)

data = {
'action': 'clear_stacklog', '_selected_action': [self.stack.id, ]}
Expand All @@ -166,4 +166,4 @@ def test_clear_stacklog(self):
self.assertEqual(response.status_code, 200)

logs = StackLog.objects.filter(stack_id=self.stack.id)
self.assertEquals(logs.count(), 0)
self.assertEqual(logs.count(), 0)
9 changes: 2 additions & 7 deletions tests/unit/test_hastexo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import time
import json
import textwrap
import pkg_resources
import os

from hastexo.models import Stack
Expand Down Expand Up @@ -50,13 +49,9 @@ class TestHastexoXBlockHTML(TestCase):
"""

def test_static(self):
static_files = ['main.html']
static_files = ['main.html', 'lab.html']
for static_file in static_files:
source = pkg_resources.resource_stream(
'hastexo',
os.path.join('static', 'html', static_file)
)
etree.parse(source,
etree.parse(os.path.join('hastexo', 'static', 'html', static_file),
etree.HTMLParser(recover=False))


Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_get_client(self):
wrapper,
get_keystone_auth=mock_get_keystone_auth):
wrapper.get_client()
self.mocks["heat_client"].Client.called_with(
self.mocks["heat_client"].Client.assert_called_with(
"1",
auth_url=self.credentials['os_auth_url'],
session="sess",
Expand All @@ -129,8 +129,8 @@ def test_get_client(self):
wrapper,
get_keystone_auth=mock_get_keystone_auth):
wrapper.get_client()
self.mocks["nova_client"].Client.called_with(
"2.0",
self.mocks["nova_client"].Client.assert_called_with(
"2.2",
self.credentials['os_username'],
self.credentials['os_password'],
project_id=self.credentials['os_project_id'],
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[tox]
envlist = flake8,pipdeptree{,-requirements},py{38,39,310,311}-xblock{17,18,19}-celery5
envlist = flake8,pipdeptree{,-requirements},py{38,39,310,311,312}-xblock{17,18,19}-celery5

[gh-actions]
python =
3.8: flake8,pipdeptree,pipdeptree-requirements,py38
3.9: flake8,pipdeptree,pipdeptree-requirements,py39
3.10: flake8,pipdeptree,pipdeptree-requirements,py310
3.11: flake8,pipdeptree,pipdeptree-requirements,py311
3.12: flake8,pipdeptree,pipdeptree-requirements,py312

[flake8]
ignore = E124,W504
Expand Down

0 comments on commit 22218f3

Please sign in to comment.