Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running tests using python 3.12 #81

Merged
merged 8 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: [quality, docs, pii_check, django32, django40]
python-version: ['3.8', '3.12']
toxenv: [quality, docs, pii_check, django42]

steps:
- uses: actions/checkout@v3
Expand All @@ -37,7 +37,7 @@ jobs:
run: tox

- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django32'
if: matrix.python-version == '3.8' && matrix.toxenv == 'django42'
uses: codecov/codecov-action@v3
with:
flags: unittests
Expand Down
2 changes: 1 addition & 1 deletion edx_event_bus_redis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
from edx_event_bus_redis.internal.consumer import RedisEventConsumer
from edx_event_bus_redis.internal.producer import create_producer

__version__ = '0.3.3'
__version__ = '0.4.0'

default_app_config = 'edx_event_bus_redis.apps.EdxEventBusRedisConfig' # pylint: disable=invalid-name
17 changes: 12 additions & 5 deletions edx_event_bus_redis/internal/tests/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Tests for message module.
"""

import re
from datetime import datetime, timezone
from uuid import UUID

Expand Down Expand Up @@ -68,14 +69,20 @@ def test_no_type(self):
)

def test_no_event_data(self):
msg = (b'1', {b'id': b'629f9892-c258-11ed-8dac-1c83413013cb', b'event_data': self.event_data_bytes})
msg = (
b'1',
{
b'id': b'629f9892-c258-11ed-8dac-1c83413013cb',
b'event_data': self.event_data_bytes,
}
)
with pytest.raises(UnusableMessageError) as excinfo:
RedisMessage.parse(msg, topic='some-local-topic')

assert excinfo.value.args == (
"Error determining metadata from message headers: "
"__init__() missing 1 required positional argument: 'event_type'",
expected_error_pattern = re.compile(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you using a regex here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test was failing due to a format change in 3.12 so i found this solution to work with both 3.8 and 3.12

r"Error determining metadata from message headers: .*__init__\(\) "
r"missing 1 required positional argument: 'event_type'"
)
assert expected_error_pattern.search(str(excinfo.value)) is not None

def test_bad_msg(self):
"""
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,12 @@ def is_requirement(line):
classifiers=[
'Development Status :: 3 - Alpha',
'Framework :: Django',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.2',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.12',
],
)
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38-django{32,40}
envlist = py{38,312}-django{42}

[pycodestyle]
exclude = .git,.tox,migrations
Expand Down Expand Up @@ -32,8 +32,8 @@ norecursedirs = .* docs requirements site-packages

[testenv]
deps =
django32: Django>=3.2,<4.0
django40: Django>=4.0,<4.1
django42: Django>=4.2,<5.0
setuptools
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the deal with requiring setuptools here, should it be in the base requirements?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is available in requirement pip.in but the tests was failing even after upgrading it to new version. I read the documentation and found this solution

https://docs.python.org/dev/whatsnew/3.12.html#summary-release-highlights

Important deprecations, removals or restrictions:

PEP 623: Remove wstr from Unicode objects in Python’s C API, reducing the size of every str object by at least 8 bytes.

PEP 632: Remove the distutils package. See the migration guide for advice replacing the APIs it provided. The third-party Setuptools package continues to provide distutils, if you still require it in Python 3.12 and beyond.

gh-95299: Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the activated virtual environment.

The asynchat, asyncore, and imp modules have been removed, along with several unittest.TestCase method aliases.

-r{toxinidir}/requirements/test.txt
commands =
python manage.py check
Expand Down Expand Up @@ -64,6 +64,7 @@ allowlist_externals =
rm
touch
deps =
setuptools
-r{toxinidir}/requirements/quality.txt
commands =
touch tests/__init__.py
Expand Down
Loading