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 Python 3.12 to CI matrix and fix Python 3.12 support. #77

Merged
merged 7 commits into from
Jun 15, 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: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", pypy2, pypy3]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12", pypy2, pypy3]

steps:
- uses: actions/checkout@v2
Expand All @@ -16,6 +16,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install setuptools
run: |
pip install setuptools

- name: Run test suite
run: |
python setup.py test
5 changes: 4 additions & 1 deletion genshi/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,13 @@ def build_code_chunk(code, filename, name, lineno):
warnings.filterwarnings('error', category=DeprecationWarning)
try:
_ast_Ellipsis = ast.Ellipsis
_ast_Ellipsis_value = lambda obj: Ellipsis
_ast_Str = ast.Str
_ast_Str_value = lambda obj: obj.s
except (AttributeError, DeprecationWarning):
_ast_Ellipsis = _ast_Str = ast.Constant
_ast_Ellipsis = ast.Constant
_ast_Ellipsis_value = lambda obj: obj.value
_ast_Str = ast.Constant
_ast_Str_value = lambda obj: obj.value

class _DummyASTItem(object):
Expand Down
12 changes: 6 additions & 6 deletions genshi/filters/tests/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -2203,12 +2203,12 @@ def test_translate_context_with_msg(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest_suite(Translator.__module__))
suite.addTest(unittest.makeSuite(TranslatorTestCase, 'test'))
suite.addTest(unittest.makeSuite(MsgDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(ChooseDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(DomainDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(ExtractTestCase, 'test'))
suite.addTest(unittest.makeSuite(ContextDirectiveTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TranslatorTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(MsgDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ChooseDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(DomainDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ExtractTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ContextDirectiveTestCase))
return suite

if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions genshi/filters/tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,8 @@ def test_sanitize_unicode_url(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest_suite(HTMLFormFiller.__module__))
suite.addTest(unittest.makeSuite(HTMLFormFillerTestCase, 'test'))
suite.addTest(unittest.makeSuite(HTMLSanitizerTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(HTMLFormFillerTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(HTMLSanitizerTestCase))
return suite


Expand Down
2 changes: 1 addition & 1 deletion genshi/filters/tests/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ def suite():
EmptyTest, RemoveTest, UnwrapText, WrapTest, FilterTest,
MapTest, SubstituteTest, RenameTest, ReplaceTest, BeforeTest,
AfterTest, PrependTest, AppendTest, AttrTest, CopyTest, CutTest):
suite.addTest(unittest.makeSuite(test, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(test))
suite.addTest(doctest_suite(
genshi.filters.transform, optionflags=doctest.NORMALIZE_WHITESPACE,
extraglobs={'HTML': HTML, 'tag': tag, 'Markup': Markup}))
Expand Down
7 changes: 5 additions & 2 deletions genshi/template/astutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""Support classes for generating code from abstract syntax trees."""

from genshi.compat import ast as _ast, _ast_Constant, IS_PYTHON2, isstring, \
_ast_Ellipsis
_ast_Ellipsis, _ast_Ellipsis_value

__docformat__ = 'restructuredtext en'

Expand Down Expand Up @@ -721,7 +721,10 @@ def visit_Subscript(self, node):
self.visit(node.value)
self._write('[')
def _process_slice(node):
if isinstance(node, _ast_Ellipsis):
if (
isinstance(node, _ast_Ellipsis)
and _ast_Ellipsis_value(node) == Ellipsis
):
self._write('...')
elif isinstance(node, _ast.Slice):
if getattr(node, 'lower', 'None'):
Expand Down
2 changes: 1 addition & 1 deletion genshi/template/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_copy(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(Template.__module__))
suite.addTest(unittest.makeSuite(ContextTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ContextTestCase))
return suite

if __name__ == '__main__':
Expand Down
20 changes: 10 additions & 10 deletions genshi/template/tests/directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,16 +1217,16 @@ def test_with_empty_value(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(directives))
suite.addTest(unittest.makeSuite(AttrsDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(ChooseDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(DefDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(ForDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(IfDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(MatchDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(ContentDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(ReplaceDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(StripDirectiveTestCase, 'test'))
suite.addTest(unittest.makeSuite(WithDirectiveTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(AttrsDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ChooseDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(DefDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ForDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(IfDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(MatchDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ContentDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ReplaceDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(StripDirectiveTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(WithDirectiveTestCase))
return suite

if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions genshi/template/tests/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,8 @@ def __init__(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(Expression.__module__))
suite.addTest(unittest.makeSuite(ExpressionTestCase, 'test'))
suite.addTest(unittest.makeSuite(SuiteTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ExpressionTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(SuiteTestCase))
return suite

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion genshi/template/tests/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def test_interpolate_triplequoted(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(interpolate.__module__))
suite.addTest(unittest.makeSuite(InterpolateTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(InterpolateTestCase))
return suite

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion genshi/template/tests/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def test_prefix_delegation_to_directories_with_subdirs(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(TemplateLoader.__module__))
suite.addTest(unittest.makeSuite(TemplateLoaderTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TemplateLoaderTestCase))
return suite

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion genshi/template/tests/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def test_directive_single_line_with_translator(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(MarkupTemplate.__module__))
suite.addTest(unittest.makeSuite(MarkupTemplateTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(MarkupTemplateTestCase))
return suite

if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions genshi/template/tests/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ def test_helper_functions(self):

def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(MarkupTemplateEnginePluginTestCase, 'test'))
suite.addTest(unittest.makeSuite(TextTemplateEnginePluginTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(MarkupTemplateEnginePluginTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TextTemplateEnginePluginTestCase))
return suite

if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions genshi/template/tests/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ def test_include_expr(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(NewTextTemplate.__module__))
suite.addTest(unittest.makeSuite(OldTextTemplateTestCase, 'test'))
suite.addTest(unittest.makeSuite(NewTextTemplateTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(OldTextTemplateTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(NewTextTemplateTestCase))
return suite

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion genshi/tests/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_markup_escape(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(Element.__module__))
suite.addTest(unittest.makeSuite(ElementFactoryTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ElementFactoryTestCase))
return suite


Expand Down
10 changes: 5 additions & 5 deletions genshi/tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ def test_curly_brace_equality(self):

def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(StreamTestCase, 'test'))
suite.addTest(unittest.makeSuite(MarkupTestCase, 'test'))
suite.addTest(unittest.makeSuite(NamespaceTestCase, 'test'))
suite.addTest(unittest.makeSuite(AttrsTestCase, 'test'))
suite.addTest(unittest.makeSuite(QNameTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(StreamTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(MarkupTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(NamespaceTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(AttrsTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(QNameTestCase))
suite.addTest(doctest_suite(core))
return suite

Expand Down
4 changes: 2 additions & 2 deletions genshi/tests/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ def test_convert_ElementTree_to_markup_stream(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest_suite(XMLParser.__module__))
suite.addTest(unittest.makeSuite(XMLParserTestCase, 'test'))
suite.addTest(unittest.makeSuite(HTMLParserTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(XMLParserTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(HTMLParserTestCase))
return suite

if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions genshi/tests/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,10 @@ def test_elem_content(self):

def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(XMLSerializerTestCase, 'test'))
suite.addTest(unittest.makeSuite(XHTMLSerializerTestCase, 'test'))
suite.addTest(unittest.makeSuite(HTMLSerializerTestCase, 'test'))
suite.addTest(unittest.makeSuite(EmptyTagFilterTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(XMLSerializerTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(XHTMLSerializerTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(HTMLSerializerTestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(EmptyTagFilterTestCase))
suite.addTest(doctest_suite(XMLSerializer.__module__))
return suite

Expand Down
2 changes: 1 addition & 1 deletion genshi/tests/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def _test_eval(self, path, equiv=None, input=None, output='',
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest_suite(Path.__module__))
suite.addTest(unittest.makeSuite(PathTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(PathTestCase))
return suite


Expand Down
2 changes: 1 addition & 1 deletion genshi/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_getitem(self):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest_suite(util))
suite.addTest(unittest.makeSuite(LRUCacheTestCase, 'test'))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(LRUCacheTestCase))
return suite

if __name__ == '__main__':
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ packages =
genshi.template.tests.templates
install_requires =
six
setup_requires =
setuptools

[options.entry_points]
babel.extractors =
Expand Down
Loading