diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index a816b1c5..f29bd4c1 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -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 @@ -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 }}) diff --git a/Changelog.md b/Changelog.md index 79ca91b1..43e3122e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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, diff --git a/hastexo/__init__.py b/hastexo/__init__.py index f4a98f18..eda0da44 100644 --- a/hastexo/__init__.py +++ b/hastexo/__init__.py @@ -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') diff --git a/hastexo/hastexo.py b/hastexo/hastexo.py index 37bcb659..0d7bf516 100644 --- a/hastexo/hastexo.py +++ b/hastexo/hastexo.py @@ -1,7 +1,6 @@ import time import logging import os -import pkg_resources import re import string import textwrap @@ -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: diff --git a/requirements/setup.txt b/requirements/setup.txt index b0d97403..767cf231 100644 --- a/requirements/setup.txt +++ b/requirements/setup.txt @@ -1,3 +1,3 @@ -r base.txt -setuptools-scm<6 +setuptools-scm bumpversion diff --git a/setup.py b/setup.py index dbc9c88e..21142c43 100755 --- a/setup.py +++ b/setup.py @@ -77,5 +77,5 @@ def package_data(pkg, roots): "migrations", "translations", "locale"]), - setup_requires=['setuptools-scm<6'], + setup_requires=['setuptools-scm'], ) diff --git a/tests/unit/test_admin.py b/tests/unit/test_admin.py index 22f42ab5..b061a8d5 100644 --- a/tests/unit/test_admin.py +++ b/tests/unit/test_admin.py @@ -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, ]} @@ -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) diff --git a/tests/unit/test_hastexo.py b/tests/unit/test_hastexo.py index 0028941b..bd023f6f 100644 --- a/tests/unit/test_hastexo.py +++ b/tests/unit/test_hastexo.py @@ -1,7 +1,6 @@ import time import json import textwrap -import pkg_resources import os from hastexo.models import Stack @@ -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)) diff --git a/tests/unit/test_openstack.py b/tests/unit/test_openstack.py index 9a1aff30..2a51ec93 100644 --- a/tests/unit/test_openstack.py +++ b/tests/unit/test_openstack.py @@ -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", @@ -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'], diff --git a/tox.ini b/tox.ini index fb78f739..9a790713 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [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 = @@ -7,6 +7,7 @@ python = 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