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

Add official support for Python 3.10 and 3.11 #288

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
Copy link
Author

Choose a reason for hiding this comment

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

It's no longer possible to install Python 3.5 and 3.6 on ubuntu-latest which now points to 22.04. They are both EOL so it's probably time to drop support for them, but that feels out of scope of this change.

strategy:
fail-fast: false
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, "pypy3"]
python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy3"]

steps:
- uses: actions/checkout@v2
Expand Down
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ premailer Changes
Peter's note: Unfortunately, ``premailer`` didn't use to keep a change log. But it's
never too late to start, so let's start here and now.

Unreleased
----------

* Add support for Python 3.9, 3.10 and 3.11. The code for the distributed code was unchanged,
only some tests needed to be adapted.

* Moved from nose test runner to pytest, as nose is no longer supported and has some known issues
with Python 3.9+.

3.10.0
------

Expand Down
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ makes sure premailer works in:
- Python 3.6
- Python 3.7
- Python 3.8
- Python 3.9
- Python 3.10
- Python 3.11
- PyPy

Turns CSS blocks into style attributes
Expand Down
32 changes: 29 additions & 3 deletions premailer/tests/test_premailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import sys
import os
import unittest
import tempfile
from contextlib import contextmanager
from io import StringIO
import tempfile
from unittest import mock

import pytest
from lxml.etree import XMLSyntaxError, fromstring
from requests.exceptions import HTTPError
import mock
import premailer.premailer # lint:ok
from nose.tools import assert_raises, eq_, ok_
from premailer.__main__ import main
from premailer.premailer import (
ExternalNotFoundError,
Expand All @@ -23,6 +23,32 @@
)


def ok_(expr, msg=None):
"""
Shorthand for assert.
Copied from Nose.
"""
if not expr:
raise AssertionError(msg)


def eq_(a, b, msg=None):
"""
Shorthand for 'assert a == b, "%r != %r" % (a, b).
Copied from Nose.
"""
if not a == b:
raise AssertionError(msg or "%r != %r" % (a, b))


def assert_raises(exc_class, func, *args):
"""Compatibility with Nose API for pytest."""
with pytest.raises(exc_class):
func(*args)
Comment on lines +26 to +49
Copy link
Author

Choose a reason for hiding this comment

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

These provide compatibility with Nose APIs. I can replace their usage in this file with direct pytest equivalent if you prefer.



whitespace_between_tags = re.compile(r">\s*<")


Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def find_version(*file_paths):

install_requires = ["lxml", "cssselect", "cssutils", "requests", "cachetools"]

tests_require = ["nose", "mock"]
tests_require = ["pytest", "pytest-cov"]

setup(
name="premailer",
Expand All @@ -45,6 +45,9 @@ def find_version(*file_paths):
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Communications",
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ envlist =
py37,
py38,
py39,
py310,
py311,
pypy3,

[gh-actions]
Expand All @@ -15,6 +17,8 @@ python =
3.7: py37
3.8: py38
3.9: py39, lint
3.10: py310
3.11: py311
pypy3: pypy3

[testenv]
Expand All @@ -24,7 +28,7 @@ install_command =
extras =
test
commands =
nosetests --with-coverage --cover-package=premailer
pytest --cov=premailer

[testenv:lint-py39]
extras = dev
Expand Down